在springMVC中添加过滤器的步骤
在web.xml中填入如下代码便可起到过滤作用
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>gb2312</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>*.ws</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
filter-mapping:为所过滤的映射,如果有多个扩展名的话可以添加多个filter-mapping
本文地址:http://www.45fan.com/bcdm/73125.html