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