struts2乱码
在spring.jar包的org.springframework.web.filter包下有个CharacterEncodingFilter.java
把spring.jar放进工程的lib里,然后在web.xml文件中<servlet>元素前加以下代码
注意要把CharacterEncodingFilter放在其他过滤器之前声明。
<!-- 著名 Character Encoding filter -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>gbk</param-value> <!-- //指定字符集 -->
</init-param>
<init-param>
<!-- //当已经有字符集时,是否用本过滤器的字符集替换 -->
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 其他某过滤器 -->
<filter>
<filter-name>eXtremeExport</filter-name>
<filter-class>
org.extremecomponents.table.filter.ExportFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>eXtremeExport</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>