而且好像在jb里面参数的传递不会乱码 但是在IE里面就会有这个问题
高手帮忙啊..

解决方案 »

  1.   

    试试这个给你一个参考:
    //***************************************************
    //名称:ChangeCode
    //功能:转换指定字符串的字符集(字符编码)
    //输入:strSource: 要转换的字符串; strCodeFrom: 源字符集; strCodeTo: 目的字符集
    //输出:
    //返回:转换之后的字符串
    //***************************************************
    public static String ChangeCode(
    String strSource,
    String strCodeFrom,
    String strCodeTo)
    {
    byte[] baTemp = null;
    try
    {
    baTemp = strSource.getBytes(strCodeFrom);
    strSource = new String(baTemp, strCodeTo);
    }
    catch (Exception e)
    {
    return (e.toString());
    } return (strSource);
    }
      

  2.   

    public static String toChinese(String orign) {
        if (orign != null) {
          try {
            orign = new String(orign.getBytes("ISO8859-1"),"GBK");      }
          catch (Exception ex) {
            System.out.println("toChinese exception:" + ex.getMessage());
            System.out.println("The String is:" + orign);
          }
        }
        System.out.println("orign"+orign);
        return orign;
      }
    我也用这个进行转换了可是还是乱码阿。
    public class MyActionServlet extends ActionServlet {
      public MyActionServlet() {
      }
      protected void process(HttpServletRequest request,
                           HttpServletResponse response) throws IOException,
        ServletException {
       request.setCharacterEncoding("GBK");
      super.process(request, response);
    }}
     <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>hrbjs.util.MyActionServlet</servlet-class>
    这是在网上找的servlet的设置 我也作了 
    但是现在是有的页面可以正常显示 有的步行..
    不知道为什么
      

  3.   

    我写了.
    import javax.servlet.Filter;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.FilterChain;
    import java.io.IOException;public class SetCharacterEncodingFilter
        implements Filter {
      protected String encoding = null;
      protected FilterConfig filterConfig = null;
      protected boolean ignore = true;  public SetCharacterEncodingFilter() {
      }  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;
        }  }  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);
           // response.setContentType("text/html;charset=" + encoding);
          }
        }    chain.doFilter(request, response);  }  public void destroy() {
        this.encoding = null;
        this.filterConfig = null;  }  protected String selectEncoding(ServletRequest request) {    return (this.encoding);  }}
    然后在web.xml进行了配置