character-encoding-filter是JavaWeb乱码过滤器。
web.xml
<filter> <filter-name>character-encoding-filter</filter-name> <filter-class>com.github.zhanhb.filter.CharacterEncodingFilter</filter-class> <init-param> <description>Encoding for content and query string, default UTF-8.</description> <param-name>characterEncoding</param-name> <param-value>UTF-8</param-value> </init-param></filter><filter-mapping> <filter-name>character-encoding-filter</filter-name> <url-pattern>/*</url-pattern></filter-mapping>如果使用了如Struts等其他框架,请把这个过滤器放在其他所有过滤器之前。
评论