【发布时间】:2010-12-06 02:54:49
【问题描述】:
Spring 3 MVC 支持所有 4 种 RESTful 方法:GET、POST、PUT 和 DELETE。但它的视图技术是否支持它们在表单上?如果不是,form:form标签中method属性的真正用途是什么?
我尝试在表单上使用 PUT 方法:
<form:form action="/myaction" method="PUT">
...
</form:form>
生成的 HTML 是:
<form id="command" action="/myaction" method="post">
<input type="hidden" name="_method" value="PUT"/>
...
</form>
从most browsers don't support other methods besides GET and POST 开始就很清楚了。但是 Spring 可以使用名称为 _method 和值 METHOD_NAME 的附加 input 来处理它。可以?
当我将指定的表单发送到带有
注释的控制器方法时@RequestMapping(method=RequestMethod.PUT)
它声称,不支持请求方法 POST。但是为什么是POST 而不是PUT?引擎盖下到底发生了什么?
【问题讨论】:
标签: spring forms spring-mvc http-method