这个东西看着就眼熟,在项目中也有用到:
@GetMapping("/msg")
public String msg() {
return "this is product's msg";
}
@GetMapping是一个组合注解,是@RequestMapping(method = RequestMethod.GET)的缩写。
@PostMapping是一个组合注解,是@RequestMapping(method = RequestMethod.POST)的缩写。
其实一般项目中是要区分get和post请求的,未避免忘记写method,应该要写getmapping或者postmapping