Spring 3 MVC支持所有4种RESTful方法:GET,POST,PUT和DELETE.但它的视图技术是否在表格上支持它们?如果没有,标签中method属性的真正用途是form:form什么?
我尝试在表单上使用PUT方法:
<form:form action="/myaction" method="PUT">
...
</form:form>
Run Code Online (Sandbox Code Playgroud)
生成的HTML是:
<form id="command" action="/myaction" method="post">
<input type="hidden" name="_method" value="PUT"/>
...
</form>
Run Code Online (Sandbox Code Playgroud)
很明显,因为除了GET和POST之外,大多数浏览器都不支持其他方法.但Spring可以通过附加input名称_method和值来处理它METHOD_NAME.可以?
当我将指定的表单发送到带注释的控制器方法时
@RequestMapping(method=RequestMethod.PUT)
Run Code Online (Sandbox Code Playgroud)
它声称,POST不支持该请求方法.但为什么POST不PUT呢?在引擎盖下实际发生了什么?