Spring MVC注解@RequestMapping和@PostMapping的区别

分类:计算机 | Spring | SpringMVC 1208
更新:2021-11-27 17:45:59
编辑

@RequestMapping

在Spring MVC中使用@RequestMapping来映射请求,也就是通过它来指定控制器可以处理哪些URL请求,相当于Servlet中在web.xml中配置。

@PostMapping

@PostMapping是一个组合注解,是@RequestMapping(method = RequestMethod.POST)的缩写。

补充

@GetMapping是一个组合注解,是@RequestMapping(method = RequestMethod.GET)的缩写。