Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported]
时间: 2023-10-17 15:31:14 浏览: 126
这个错误是由于前端以POST方法提交表单,而后台代码中没有对POST方法进行支持所导致的。引用中的代码片段显示了一个使用@PostMapping注解的方法,该方法接受一个Dishes对象,并将其保存到数据库中。然而,在该方法中并没有对POST方法进行支持。因此,当以POST方法访问该接口时,会抛出"POST"方法不支持的异常。解决这个问题的方法是,在接受Dishes对象的参数前添加@RequestBody注解,如引用中的代码所示。这样可以告诉Spring将请求体中的数据绑定到Dishes对象上。通过这种方式,就可以正确地处理POST请求了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [org.springframework.web.HttpRequestMethodNotSupportedException: Request method ‘POST‘ not ...](https://blog.csdn.net/weixin_45410366/article/details/125613217)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method ‘POST‘ ...](https://blog.csdn.net/m0_52861000/article/details/130489613)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文