写一个filter
EncodingFilter
配置
URL为 /*

解决方案 »

  1.   

    加一个过滤器,每次网页先经过filter,
    还有页面的编码方式都改成utf-8.
      

  2.   

    ApplicationResources_zh.properties 是国际化的方法,必须要用UTL-8编码,会有比较大的麻烦
    还是写过滤器吧
      

  3.   

    utf-8把你不转死才怪!struts的中文问题一般包括:
    1.insert进数据库的编码和数据库默认字符集不一致;
    eg ,mysql4.1.11,mysql5默认为lain1,把myini中server,client的字符集该为default-character=GBK;(要加两次);
    新建数据库时候把数据库默认字符集设为GBK
    2.提交数据页面字符集和数据库字符集不一致;
    这个google一下不过是转码;
    我遇到的问题都是这样解决,不对地方别砖!!!!
      

  4.   

    EncodingFilter
    package demo;import javax.servlet.*;
    import java.io.IOException;
    public class EncodeFilter implements Filter {
    protected String encoding = null;
    protected FilterConfig filterConfig = null;
    protected boolean ignore = true;
    public void destroy() {
        this.encoding = null;
        this.filterConfig = null;
    }
    public void doFilter(ServletRequest request, ServletResponse response,
                          FilterChain chain)
    throws IOException, ServletException {
       if (ignore || (request.getCharacterEncoding() == null)) {
         String encoding = selectEncoding(request);
         if (encoding != null)
           request.setCharacterEncoding(encoding);
       }
       chain.doFilter(request, response);
    }
    public void init(FilterConfig filterConfig) throws ServletException {
        this.filterConfig = filterConfig;
        this.encoding = filterConfig.getInitParameter("encoding");
        String value = filterConfig.getInitParameter("ignore");
        if (value == null)
          this.ignore = true;
        else if (value.equalsIgnoreCase("true"))
          this.ignore = true;
        else if (value.equalsIgnoreCase("yes"))
          this.ignore = true;
        else
          this.ignore = false;
    }
    protected String selectEncoding(ServletRequest request){
    return (this.encoding); 
    }
    }
    配置文件:<filter>
    <filter-name>Set Character Encoding</filter-name>
    <filter-class>demo.EncodeFilter </filter-class>
    <init-param>
    <param-name>encoding</param-name>
    <param-value>gb2312</param-value>
    </init-param>
    <init-param>
    <param-name>ignore</param-name>
    <param-value>true</param-value>
    </init-param>
    </filter>