当数据量一大,用ie就可能存在个别汉字乱码,chrome,ff等就没有乱码,后台filter、jsp页面都声明了gb2312编码,感觉很疑惑,求解中

解决方案 »

  1.   

    编码都改成utf-8吧,传中文参数的时候不要用get方法,也不要直接用?传
      

  2.   

    字符编码的过滤器 import  javax.servlet. * ; 
     import  java.io.IOException; 
     
      /** */ /**  
     * 用于设置 HTTP 请求字符编码的过滤器,通过过滤器参数encoding指明使用何种字符编码,用于处理Html Form请求参数的中文问题 
     */  
     public   class  CharacterEncodingFilter 
     implements  Filter 
       { 
     protected  FilterConfig filterConfig  =   null ; 
     protected  String encoding  =   "" ; 
     
     public   void  doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)  throws  IOException, ServletException 
       { 
     if (encoding  !=   null ) 
     servletRequest.setCharacterEncoding(encoding); 
     filterChain.doFilter(servletRequest, servletResponse); 
     }  
     
     public   void  destroy() 
       { 
     filterConfig  =   null ; 
     encoding  =   null ; 
     }  
     
     public   void  init(FilterConfig filterConfig)  throws  ServletException 
       { 
     this .filterConfig  =  filterConfig; 
     this .encoding  =  filterConfig.getInitParameter( " encoding " ); 
     
     }  
     }  
      

  3.   

    1. 前后端的编码格式要一致(项目)
    2. 过滤器要去检查是否设置成功
    3.异步。要求设置编码格式 这个不要再相信的过滤器 有时候是没有最用
    4.发送请求的时候 method=“post”