<%@ page language="java" contentType="text/html; charset=GBK"
    pageEncoding="GBK"
%>
String name = request.getParameter("name"); 接收过来的name是汉字
response.sendRedirect("LoginOk.jsp?name="+name);当跳转到LoginOk.jsp页面后,
 request.setCharacterEncoding("gbk");
 String name = request.getParameter("name");<body>
    <center>欢迎你
      <%=name %><a href = "index.jsp">首页</a>
    </center>
</body>然后就出错了,页面中间是乱码!
LoginOk.jsp的也是<%@ page language="java" contentType="text/html; charset=GBK"
    pageEncoding="GBK"%>为什么,急啊,想了老半天了!!

解决方案 »

  1.   

    String name = request.getParameter("name"); 
    Systemm.out.println(name);到控制台看看是不是乱码
      

  2.   

    response.sendRedirect("LoginOk.jsp?name="+name);是不是这句话有问题啊?
      

  3.   

    response.sendRedirect不能传中文,需要转换,String name = new   String(request.getParameter("name").getBytes("ISO8859_1"),   "GBK"));
      

  4.   

        String url = "LoginOk.jsp?name="+name;
        url=new String(url.getBytes("ISO-8859-1"),"GBK");    
        response.sendRedirect(url);
    我是这样写的,怎么还出错啊??高手请指教啊,谢谢了,急呀!
      

  5.   

    request.getParameter("name"); 默认的就是以iso88591的格式解析的,遇到中文当然是乱码。
      

  6.   

    在接受参数的时候转换
    String name =new String( request.getParameter("name").getBytes(iso-8859-1),"gbk");
    还不行的话将"gbk"改为"gb2312"或"UTF-8"试试
      

  7.   

    其实乱码问题 很好处理的 
    你从数据库取出来时 转码 ISO-8859-1  JSP页面显示时 转码 GBK
    ISO-8859-1是个标准 呵呵这样就不会出现乱码了
      

  8.   

    把传过来的name用此语句进行转换
    String name =new String( request.getParameter("name").getBytes(iso-8859-1),"gbk");
      

  9.   

    呵呵 这个我刚好学了 除了要用String name = new  String(request.getParameter("name").getBytes("ISO8859_1"),  "GBK")); 转换外  response.sendRedirect("LoginOk.jsp?name="+name);必须改为 response.sendRedirect("LoginOk.jsp?name="+URLEncoder.encode(name));
      

  10.   

    还有就是不能用request.setCharacterEncoding("GBK") 的,只能
    用String name = new  String(request.getParameter("name").getBytes("ISO8859-1"),  "GBK"));
      

  11.   

    以下是源代码:求高人指点呀!研究了一个下午了,头都大了!<%
     request.setCharacterEncoding("gbk"); 
     String name = request.getParameter("name");//out.print(name);
     String pwd = request.getParameter("pwd");//out.print(pwd);
          
        name = new String(name.getBytes("iso-8859-1"),"gbk"); 
        response.sendRedirect("LoginOk.jsp?name="+name);
     %>
    下面是LoginOk.jsp页面
    <%
     request.setCharacterEncoding("gbk");
     //String name = request.getParameter("name");
     String name =new String( request.getParameter("name").getBytes("iso-8859-1"),"gbk");
     System.out.println(name);
     %>
     输出来的是乱码!!
      

  12.   

    是tomcat的问题~   改server.xml    URLEncoding="gb2312"   编码随便你改  不出现乱码就行了
      

  13.   

    米错,过滤器该是最好的方法了简单点的,你把这个页面的属性窗口打开,设成utf-8,然后把页面最上面的指令里面也设成utf-8,在页面中转页之前 把编码也改成utf-8,如果还不行就加过滤器吧
      

  14.   

    response.sendRedirect("LoginOk.jsp?name="+name);
    URL是不可以传中文的。URL ENCODER之后,才可以传。。然后再URL DECODER
      

  15.   

    提交表单用 post 看下能行不?
      

  16.   

    我写过一个关于简单处理乱码问题的博文,可以供你参考一下.但是文中所写的并不是最佳的处理方式.
    文章位于:http://blog.csdn.net/auditionlsl/article/details/4208294今天恰巧有人对这篇文章留言,回复过后,我本来是来Java版块提问的。呵呵.提问题去了。
      

  17.   

    又是乱码问题,看下我这篇文章吧,希望对你有用。
    http://blog.csdn.net/wgw335363240/article/details/6059489
      

  18.   

    万恶的 pageEncoding="GBK",楼主节哀吧
      

  19.   

    要么你用个过滤器,写上request.setCharacterEncoding("utf-8");response.setCharacterEncoding("utf-8");
    要么你在重定向前写上request.setCharacterEncoding("utf-8");
    当然取出的时候还是new String(str.getBytes("iso-8859-1"),"utf-8");
    这样试下,前提是所有的编码格式一致,楼上的就发现你的编码不一致。
      

  20.   

    web容器里面要设置过的,如果想要通过url传参不乱码的话。。就像tomcat的话,在那个server.xml里面,找到那个uri的什么地方,改成utf-8.