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 {

 

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