SpringMVC的Restful中PUT無法獲取參數問題(SSL設置)

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章