日期:2014-05-20 浏览次数:20693 次
contentType="text/html; charset=GBK" pageEncoding="GBK" java文件编码:GBK
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { request.setCharacterEncoding("GBK"); chain.doFilter(request, response); }
<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>
------解决方案--------------------
字符转换一下
String str = new String(request.getAttribute("元素名").getBytes("ISO8859_1"),"GBK");
------解决方案--------------------
在struts.xml中配置i18n
<constant name="struts.i18n.encoding" value="GB18030"></constant>