Request method 'POST' not supported

蹲街弑〆低调 提交于 2019-12-21 09:26:23

问题


According to the 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).

They have done the latter, and can be achieved with the following spring MVC form tag:

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

The problem is when i click 'Delete' my page throws the following error:

HTTP Status 405 - Request method 'POST' not supported

I changed the debug level of org.springframework.web to debug and found the following message:

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

I used RestClient with DELETE method and the method is called as expected. What am I doing wrong here?


回答1:


You need to configure HiddenHttpMethodFilter in your web.xml

Details can be found here:



来源:https://stackoverflow.com/questions/4093611/request-method-post-not-supported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!