解决DELETE PUT请求方式无法提交表单数据的问题

1.在web.xml中配置过滤器


<filter>
    <filter-name>HiddenHttpMethodFilterfilter-name>
    <filter-class>org.springframework.web.filter.HiddenHttpMethodFilterfilter-class>
filter>
<filter-mapping>
    <filter-name>HiddenHttpMethodFilterfilter-name>
    <url-pattern>/*url-pattern>
filter-mapping>

2.在表单中发送POST请求

method=”post”
添加隐藏域(name=”_method” value=”PUT/DELETE”)

type="hidden" name="_method" value="DELETE" />

3.配置支持对应请求方式

@RequestMapping(method = RequestMethod.DELETE)

你可能感兴趣的:(技术博客)