Spring-webmvc

@RequestMapping

2019-07-09  本文已影响0人  xzz4632

1. RequestMapping注解:

2. 注解参数

2.1 value

定义请求uri. 同path

2.2 path

除了定义确定的uri以外还可以使用以下符号:

注:spring mvc默认提供了.作为请求的后缀. 但是这在使用URI变量时可能会引发歧义.

2.3 params

定义参数过滤条件, String数组类型.

2.4 headers

params.
注:headers在接收content-type, accept参数时还支持通配符*. *号用于匹配/后面的部分.

2.5 consumes

指定可消费的Media Type, 即匹配content-type参数. 可用!表示否定. 即除此之外.

consumes = "text/plain"
 consumes = {"text/plain", "application/*"}
consumes = "!text/plain" // 表示否定
2.6 produces

可生成的Media Type. 匹配请求的Accept参数. 可用!表示否定.

produces = "text/plain"
 produces = {"text/plain", "application/*"}
 produces = MediaType.APPLICATION_JSON_UTF8_VALUE
2.7 name

为这个映射分配一个名称

2.8 method

定义这个请求的请求方式.

上一篇 下一篇

猜你喜欢

热点阅读