注解 | 说明 | 实例 |
@RequestParam | 将请求参数绑定到你控制器的方法参数上 | public ModelAndView test16(@RequestParam("name")String name) |
@PathVariable | 接收请求路径中占位符的值 | 1.@RequestMapping("/{id}") public RespBean deleteDepById(@PathVariable Integer id) {将请求中的id 绑定到 参数id} 2.@RequestMapping("/{id}/{name}") public void test(@PathVariable("id") Integer ids,@PathVariable("name") String name) |
@RequestBody | 将json格式的数据转为java对象 | @PostMapping("/") public RespBean addUser(@RequestBody User user) { 将数据绑定到 User 对象上} |