在Spring4.3中引进了新注释,来帮助简化常用的HTTP方法的映射,并更好地表达被注解方法的语义。
- @GetMapping
- @PostMapping
- @PutMapping
- @DeleteMapping
- @PatchMapping
@GettMapping 处理get请求
//传统写法
@RequestMapping(value = "getId", method = RequestMethod.GET)
//新方法简写
@GetMapping("/get/{id}")
@PostMapping 处理post请求
//传统写法
@RequestMapping(value = "getId", method = RequestMethod.POST)
//新方法简写
@PostMapping("/get/{id}")