问题:使用SpringMVC的Restful风格构建服务时,调用PUT方法时无法获取参数。
解决方法:在web.xml配置HttpPutFormContentFilter
<!-- 隐藏的HttpMethod方法过滤器,表单提交中需要携带一个name=_method的隐藏域,value=put或者delete --> <filter> <filter-name>HiddenHttpMethodFilter</filter-name> <filter-class>org.springframework.web.filter.HttpPutFormContentFilter</filter-class> </filter> <filter-mapping> <filter-name>HiddenHttpMethodFilter</filter-name> <servlet-name>dispatcherServlet</servlet-name> </filter-mapping> <security-constraint> <web-resource-collection> <web-resource-name>SSL</web-resource-name> <url-pattern>/rest/sys/login</url-pattern> </web-resource-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint>注:下面的为项目SSL配置项。
本文介绍在使用SpringMVC构建RESTful风格服务时,遇到PUT方法无法获取参数的问题,并通过配置HttpPutFormContentFilter解决此问题。文章详细解释了配置步骤和其原理,帮助开发者避免常见错误。
1741

被折叠的 条评论
为什么被折叠?



