@GetMapping和@PostMappinng
顾名思义表示的是请求方式;
有一个注意点是:
程序中如果使用了@PostMapping,很有可能造成浏览器无法访问路径,405错误:method not allowed, The specified HTTP method is not allowed for the requested resource.
主要原因还是在于,浏览器发送Get请求,而方法只能处理post请求。
解决方法很简单:
不论mac还是windows都可以下载一个插件叫postman,然后可以改变浏览器发送请求的方式了此外,还有@RequestMapping表示两者请求(GET和post都支持),但最好不要选择,因为有针对性的更好。