@PathVariable、@RequestParam、@RequestBody的区别
2017-06-29 20:42
806 查看
一、@PathVariable的url是这样的:http://host:port/.../path/参数值
http://127.0.0.1/xx/xx/deleteGroup/1
例如:
@RequestMapping(value = "deleteGroup/{id}", method= RequestMethod.GET)
public void deleteGroupById(@PathVariable Long Id) {
}
二、@RequestParam的url是这样的:http://host:port/.../path?参数名=参数值
http://127.0.0.1/xx/xx/add?name=xx&years=xx
例如:
@RequestMapping(value = "/add", method = RequestMethod.POST)
public void add(@RequestParam("name") String name, @RequestParam("years") int years){
}
三、@RequestBody的url是这样的:http://host:port/.../path但是得传入json对象的body。
@RequestMapping(value = "/add", method = RequestMethod.POST)
public void add(@RequestBody User user) {
}
http://127.0.0.1/xx/xx/deleteGroup/1
例如:
@RequestMapping(value = "deleteGroup/{id}", method= RequestMethod.GET)
public void deleteGroupById(@PathVariable Long Id) {
}
二、@RequestParam的url是这样的:http://host:port/.../path?参数名=参数值
http://127.0.0.1/xx/xx/add?name=xx&years=xx
例如:
@RequestMapping(value = "/add", method = RequestMethod.POST)
public void add(@RequestParam("name") String name, @RequestParam("years") int years){
}
三、@RequestBody的url是这样的:http://host:port/.../path但是得传入json对象的body。
@RequestMapping(value = "/add", method = RequestMethod.POST)
public void add(@RequestBody User user) {
}
相关文章推荐
- @PathVariable,@RequestParam, @RequestBody,@ModelAttribute,@RequestHeader,@CookieValue的区别
- @PathVariable,@RequestParam, @RequestBody,@ModelAttribute,@RequestHeader,@CookieValue的区别
- @RequestMapping @PathVariable @ResponseBody @RequestParam的区别
- @PathVariable和@RequestParam的区别
- springmvc中@PathVariable和@RequestParam的区别
- @RequestParam @RequestBody @PathVariable 等参数绑定注解详解(转)
- @RequestParam @RequestBody @PathVariable 等参数绑定注解详解
- @RequestParam @RequestBody @PathVariable 等参数绑定注解详解
- @PathVariable和@RequestParam的区别
- @PathVariable 、@RequestHeader、@CookieValue、@RequestParam, @RequestBody
- @RequestParam @RequestBody @PathVariable 等参数绑定注解详解
- SpringMVC使用@PathVariable,@RequestBody,@ResponseBody,@RequestParam,@InitBinder
- @RequestParam,@PathVariable,@ResponseBody,@RequestBody,@ModelAttribute学习
- @PathVariable和@RequestParam的区别
- @RequestParam @RequestBody @PathVariable 等参数绑定注解详解
- @RequestParam @RequestBody @PathVariable 等参数绑定注解详解
- @RequestParam @RequestBody @PathVariable 等参数绑定注解详解
- springmvc中@PathVariable和@RequestParam的区别
- @RequestParam @RequestBody @PathVariable 等参数绑定注解详解
- @RequestParam @RequestBody @PathVariable 等参数绑定注解详解