1.在web.xml文件中配置
<!-- HiddenHttpMethodFilter过滤器可以将POST请求转化为put请求和delete请求! --> <filter> <filter-name>hiddenHttpMethodFilter</filter-name> <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class> </filter> <filter-mapping> <filter-name>hiddenHttpMethodFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
2.在表单域中
需要携带一个name值为_method,value值为put或者delete的参数,如下所示:
<form action="${pageContext.request.contextPath }/order/1" method="post"> <input type="hidden" name="_method" value="put"/> <input type="submit" value="Submit"/> </form> <form action="${pageContext.request.contextPath }/order/1" method="post"> <input type="hidden" name="_method" value="delete"/> <input type="submit" value="Submit"/> </form>