使用過濾器是在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>