1. 程式人生 > >@GetMapping和@PostMapping 和@RequestMapping區別

@GetMapping和@PostMapping 和@RequestMapping區別

@GetMapping 用於將HTTP GET請求對映到特定處理程式方法的註釋。

具體來說,@GetMapping是一個作為快捷方式的組合註釋@RequestMapping(method = RequestMethod.GET)

@PostMapping 用於將HTTP POST請求對映到特定處理程式方法的註釋。

具體來說,@PostMapping是一個作為快捷方式的組合註釋@RequestMapping(method = RequestMethod.POST)

此外還有@PutMapping@PatchMapping@DeleteMapping同上

所以一般情況下都是用@RequestMapping(method=RequestMethod.

即可