使用过滤器是在web.xml中使用filter,以下是码过滤器,过滤所有资源的使用
web.xml
<filter> <filter-name>setCharactor</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>setCharactor</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>