背景:spring是支持rest風格的請求的。
spring在處理請求的時候,可以通過參數指定處那種類型的其請求。
比如:@RequestMapping(value="/user/login",method=RequestMethod.POST)
代表處理post請求。
spring爲了簡單,於是有了
@PostMapping ,接受post請求
@RequestMapping(method = RequestMethod.POST)
public @interface PostMapping {
@GetMapping
@RequestMapping(method = RequestMethod.GET)
public @interface GetMapping {
@PutMapping
@RequestMapping(method = RequestMethod.PUT)
public @interface PutMapping {
@DeleteMapping
@RequestMapping(method = RequestMethod.DELETE)
public @interface DeleteMapping {