Can Spring MVC handle requests from HTML forms other than POST and GET?

。_饼干妹妹 提交于 2019-12-02 21:02:37

The use of the "hidden parameter" called _method is not specific to Spring MVC's tag library, but is also used by a few other client frameworks. Spring is just following the convention, such as it is.

In order to use this properly, you need to add a filter to your web.xml, (HiddenHttpMethodFilter, see javadoc), which turns the _method parameter into a "real" HTTP method representation in the HttpServletRequest. This is done as a filter to emphasise the fact the the lack of PUT and DELETE is a browser problem - the servlet API supports it just fine.

So if you want to use these methods in your form, you need to add that filter.

P.S. The reason you get the "POST not supported" message is that your form uses POST, and your handler is annotated with PUT, so it doesn't match. Because you don't have the filter defined, the _method parameter is ignored.

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