在一个WEB服务器上共享多个应用程序session的时候,发现一个中文乱码问题一直解决不了,希望各位大侠指教。访问servlet的路径是:http://localhost:8029/ServletContext/servlet/ShareSessionservlet
先试了两种解决方案:
1、
String font="中国子怎么了?";
//temp = new String(temp.getBytes("8859_1"), "GB2312")
font=new String(font.getBytes("iso-8859-1"),"gb2312");
out.println("<br>"+font+"--what?");没有效果
1、在doGet(HttpServletRequest request,HttpServletResponse response)方法的头部:request.setCharacterEncoding("GBK");和request.setCharacterEncoding("GBK");没有效果

解决方案 »

  1.   

    font=new String(font.getBytes("iso-8859-1"),"gbk");
      

  2.   

    改成:
    font=new String(font.getBytes("iso-8859-1"),"gbk"); 
    font=new String(font.getBytes("iso-8859-1"),"utf-8");
    都没有用
     
      

  3.   

    你在程序里定义的中文,没必要转吧,接受如果print乱了再转name = new String(name.getBytes("ISO8859_1"),"GBK");
      

  4.   

    1在doGet(HttpServletRequest request,HttpServletResponse response)方法的头部:request.setCharacterEncoding("GBK");和request.setCharacterEncoding("GBK");
    在这个方法之后再加入:response.setContentType("gb2312");
    试试,因为你是共享多个应用程序session不只有获取数据方面的设置,输出也要设置
    你先试试
      

  5.   

    可以试一下在设置contentType属性