[org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported]
时间: 2023-11-03 09:02:08 浏览: 52
这个错误提示说明你的请求方法不被支持。根据提供的代码和引用内容,你在前端使用了Post方法提交表单,但是后台接口使用了@PostMapping注解来映射该请求。@PostMapping注解等同于@RequestMapping(method = RequestMethod.POST),它只支持Post请求。所以当你使用Get方法访问该接口时,就会报错"Request method 'GET' not supported"。为了解决这个问题,你可以将前端的请求方法改为Post,或者将后台的注解改为@GetMapping,这样就可以支持Get请求了。
相关问题
Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method GET not supported
这个错误通常是因为你的请求方法不被服务器支持,比如你发送了一个 GET 请求,但是服务器只支持 POST 请求。你需要确认一下你的请求方法是否正确,并且检查一下服务器的接口文档,了解服务器支持的请求方法。如果你确定请求方法正确,但是还是出现这个错误,可能是服务器出现了故障,你需要联系服务器管理员进行排查。
org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'PUT' not supported
当你看到org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'PUT' not supported的错误消息时,它意味着你正在尝试使用PUT请求方法,但该方法在你的代码中并未被支持。
这通常是因为你的代码中没有相应的处理程序方法来处理PUT请求。在你的代码中,你使用了@PostMapping注释来映射HTTP POST请求到特定的处理程序方法。但是,你需要使用@RequestMapping注释来映射HTTP PUT请求到相应的处理程序方法,或者使用@PutMapping注释作为快捷方式来映射HTTP PUT请求。
简而言之,你需要在你的代码中添加一个处理程序方法,并使用@RequestMapping或@PutMapping注释将该方法映射到HTTP PUT请求。这样,当你使用PUT请求时,就不会再出现org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'PUT' not supported的错误了。<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 ‘GET‘ not supported](https://blog.csdn.net/weixin_45157411/article/details/123665632)[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_1"}}] [.reference_item style="max-width: 50%"]
- *2* [Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method ‘GET‘ not...](https://blog.csdn.net/qq_44347175/article/details/125697957)[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_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]