区别如下下:
@GetMapping用于将HTTP get请求映射到特定处理程序的方法注解
具体来说,@GetMapping是一个组合注解,是@RequestMapping(method = RequestMethod.GET)的缩写。
@PostMapping用于将HTTP post请求映射到特定处理程序的方法注解
具体来说,@PostMapping是一个组合注解,是@RequestMapping(method = RequestMethod.POST)的缩写
检验第一个使用的是GetMapping,第二个使用的是@RequestMapping:
@GetMapping("/getRule")
public Rule getRule(){
Rule rule=new Rule(" @GetMapping","404");
return rule;
}
@RequestMapping(method = RequestMethod.GET ,value = "/getRule2")
public Rule getRule2(){
Rule rule=new Rule("@RequestMapping(method = RequestMethod.GET ","404");
return rule;
}
使用的是GetMapping
使用的是@RequestMapping