加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 不支持请求方法’POST’

发布时间:2020-12-15 03:07:35 所属栏目:Java 来源:网络整理
导读:根据 Spring Documentation here: While HTTP defines these four methods,HTML only supports two: GET and POST. Fortunately,there are two possible workarounds: you can either use JavaScript to do your PUT or DELETE,or simply do a POST with th
根据 Spring Documentation here:

While HTTP defines these four methods,HTML only supports two: GET and POST. Fortunately,there are two possible workarounds: you can either use JavaScript to do your PUT or DELETE,or simply do a POST with the ‘real’ method as an additional parameter (modeled as a hidden input field in an HTML form).

他们已经完成了后者,并且可以使用以下spring MVC表单标签来实现:

<form:form method="delete">
   <input type="submit" value="Delete"/>
</form:form>

问题是,当我单击“删除”时,我的页面会抛出以下错误:

HTTP Status 405 - Request method 'POST' not supported

我将org.springframework.web的调试级别更改为debug并找到以下消息:

DEBUG AnnotationMethodHandlerExceptionResolver - Resolving exception from handler [foo.bar.MessageForm@da9246]:
org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported

我使用RestClient和DELETE方法,并按预期调用该方法.我在这做错了什么?

解决方法

您需要在web.xml中配置HiddenHttpMethodFilter

细节可以找到here:

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读