@RequestMapping 源码
起个名字
[email protected] 注解中value 和path的区别
在官方注释中可以看到 value 和 path 属性 都有@AliasFor注解,而且互为别名,由此可知2者没有区别,哈哈哈哈
看下path属性的官方注释,value也是一样的
1.支持ant-style
Ant-style path patterns are also supported
2.支持通配符(value也是支持的),用通配符时可以和@PathVariable 注解一起用
Path mapping URIs may contain placeholders (e.g.
“/${profile_path}”
).
- 3.可以用于类型上和方法上,用于类型上时,可以缩短方法的查询范围
When used at the type level, all method-level mappings inherit this primary mapping, narrowing it for a specific handler method
和我们用起来是一样一样的
2 method
用来匹配http请求的方法类型,方法类型点数组就可以看到了
GET, POST, HEAD, OPTIONS, PUT, PATCH, DELETE, TRACE.
3.params
貌似用的很少,这个就是要求请求参数中要有属性对应属性和值
例如:
这个请求参数必须有myParam=1
http://localhost:9092/hello?myParam=1&twoParam=2
4.headers
指定request中必须包含某些指定的header值
5 consumes
限制提交内容类型(Content-Type),例如application/json, text/html等,经常用在安全扫描中
6.produces
限制返回类型,和consumes相反