pring MVC过滤器-HttpPutFormContentFilter
生活随笔
收集整理的這篇文章主要介紹了
pring MVC过滤器-HttpPutFormContentFilter
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
? ? 在Spring MVC過濾器-HiddenHttpMethodFilter中我們提到,jsp或者說html中的form的method值只能為post或get,我們可以通過HiddenHttpMethodFilter獲取put表單中的參數-值,而在Spring3.0中獲取put表單的參數-值還有另一種方法,即使用HttpPutFormContentFilter過濾器。
? ? ? ? HttpPutFormContentFilter過濾器的作為就是獲取put表單的值,并將之傳遞到Controller中標注了method為RequestMethod.put的方法中。
? ? ? ? 在web.xml中配置HttpPutFormContentFilter的代碼類似如下:
<filter> <filter-name>httpPutFormcontentFilter</filter-name> <filter-class>org.springframework.web.filter.HttpPutFormContentFilter</filter-class> </filter> <filter-mapping> <filter-name>httpPutFormContentFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>?需要注意的是,該過濾器只能接受enctype值為application/x-www-form-urlencoded的表單,也就是說,在使用該過濾器時,form表單的代碼必須如下:
?
<form action="" method="put" enctype="application/x-www-form-urlencoded"> ...... </form>?
?
總結
以上是生活随笔為你收集整理的pring MVC过滤器-HttpPutFormContentFilter的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Core Linux折腾(二)
- 下一篇: C++ STL vector(向量)