springmvc教程-@PostMapping、@GetMapping、@PutMapping、@DeleteMapping

介绍

spring mvc中,有很多简化注解,@PostMapping、@GetMapping、@PutMapping、@DeleteMapping 是 @RequestMapping注解的简化版

@PostMapping

只处理 post 请求

@PostMapping("/login") 是下面的简化写法:
@RequestMapping(value = "/login",method = RequestMethod.POST)

@GetMapping

只处理 get 请求

@GetMapping("/query") 是下面的简化写法:
@RequestMapping(value = "/query",method = RequestMethod.GET)

@PutMapping

只处理 put 请求。一般用于 restful 风格,表示更新

@GetMapping("/student") 是下面的简化写法:
@RequestMapping(value = "/student",method = RequestMethod.PUT)

@DeleteMapping

只处理 delete 请求。一般用于 restful 风格,表示删除

@DeleteMapping("/student") 是下面的简化写法:
@RequestMapping(value = "/student",method = RequestMethod.DELETE)


原文出处:/show_1IX5QETC4BC.html