@RequestMapping在spring早期版本中一直存在,我也一直在使用。不过在Spring 4.3中,引入了@GetMapping、@PostMapping、@PutMapping、@DeleteMapping、@PatchMapping,用来帮助简化常用的Http方法映射,并更好地表达了被注解方法的语义。
以@GetMapping为例,从其源码中可以看出,它其实是一个组合注解,是@RequestMapping(method = RequestMethod.GET)的缩写
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@RequestMapping(method = RequestMethod.GET)
public @interface GetMapping {
...
}