@RequestMapping理论分析,属性详解
来源:互联网 发布:安徽综艺频道网络电视 编辑:程序博客网 时间:2024/06/02 03:01
@RequestMapping注解详解
@RequestMapping是一个用来处理请求地址映射的注解,可用于类或者方法上。用于类上,表示类中的所有响应请求的方法都是以该地址作为父路径。@RequestMapping注解有六个属性,下面进行详细的说明。
1.value, method.
value:指定请求的实际地址,指定的地址可以是URI Template模式。
method:指定请求的method类型,GET、POST、PUT、DELETE等。
2.consumes, produces.
consumes:指定处理请求的提交内容类型(Content-Type),例如application/json,text/html;
produces:指定返回的内容类型,仅当request请求头中的(Accept)类型中包含该指定类型才返回;
3.params, headers.
params:指定request中必须包含某些参数值才让该方法处理。
headers:指定request中必须包含某些指定的header值,才能让该方法处理请求。
handler method参数绑定常用的注解,根据他们处理的request的不同内容部分分为四类:
A:处理request uri部分的注解:@PathVariable;
B:处理request header部分的注解:@RequestHeader, @CookieValue;
C:处理request body部分的注解:@RequestParam, @RequestBody;
D:处理attribute类型的注解:@SessionAttributes, @ModelAttribute;
1.@PathVariable
当使用@RequestMapping URI template样式映射时,即someUrl/{paramId},这时的paramId可通过@PathVariable注解绑定它传过来的值到方法的参数上。
2.@RequestHeader、@CookieValue
@RequestHeader注解可以把Request请求header部分的值绑定到方法的参数上。
@CookieValue可以把Request header中关于cookie的值绑定到方法的参数上。
- @RequestMapping理论分析,属性详解
- Spring MVC之@RequestMapping 详解(各种属性详解)
- 详解@RequestMapping
- @RequestMapping详解
- @RequestMapping详解
- @RequestMapping详解
- @RequestMapping的produces属性
- [@Controller]2 详解@RequestMapping
- [@Controller]2 详解@RequestMapping
- [@Controller]2 详解@RequestMapping
- [@Controller]2 详解@RequestMapping
- @RequestMapping 用法详解
- [@Controller]2 详解@RequestMapping
- SpringMVC RequestMapping 参数详解
- Spring Mvc @RequestMapping 详解
- SpringMVC RequestMapping注解详解
- spring @RequestMapping参数详解
- @RequestMapping的用法详解
- JXTA 点对点管道通信
- python的第一步
- Linux内核tracepoints
- Android adb 使用学习【持续更新...】
- windows关闭防火墙
- @RequestMapping理论分析,属性详解
- webservice-WSDL结构与各元素解析
- hdu 1009 贪心算法
- Rxjava
- 135_容器_guava之_只读_函数式编程(过滤、转换、组合 )_约束_集合
- JS中判断null、undefined与NaN的方法
- 超市小票改进版本
- iOS UIStoryboardSegue
- 就当补漏收藏夹。。