springmvc接收参数

[email protected]和@RequestParam的区别
请求路径上有个id的变量值,可以通过@PathVariable来获取 @RequestMapping(value = "/page/{id}", method = RequestMethod.GET)
[email protected]用来获得静态的URL请求入参 spring注解时action里用到。
简介:
handler method 参数绑定常用的注解,我们根据他们处理的Request的不同内容部分分为四类:(主要讲解常用类型)
A、处理**requet uri **部分这里指uri template中variable,不含queryString部分)的注解: @PathVariable;

B,处理request header部分的注解: @RequestHeader, @CookieValue;
图示:

springmvc接收参数
image.png

C、处理request body部分的注解:@RequestParam, @RequestBody;

springmvc接收参数
image.png
springmvc接收参数
image.png

D、处理attribute类型是注解: @SessionAttributes, @ModelAttribute;