問題:使用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配置項。