spring----註解@PostMapping &@GetMapping &@PutMapping &@DeleteMapping

背景: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 {

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章