<%@ page contentType="text/html;charset=gb2312" %>
加上就没问题了。加上之后先不要转码试试。不行再用转码。

解决方案 »

  1.   

    在head之间加这个试试
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
      

  2.   

    不管用
    这是我读cookie的源代码
    <%@page contentType="text/html;charset=gb2312" language="java"%>
    <%@page import="java.sql.*,java.util.*"%>
    <%@page errorPage="handleError.jsp"%>
    <html>
    <head>........(中间略)
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <body>
    <table border=1>
    <tr><td>Name</td><td>value</td></tr>
    <%
    Cookie cookies[]=request.getCookies();
    Cookie sCookie=null;
    String svalue=null;
    String sname=null;
    for(int i=0;i<cookies.length;i++)
    {
    sCookie=cookies[i];
    svalue=new String(sCookie.getValue().getBytes("gb2312"),"ISO_8859_1");
    svalue=sCookie.getValue();
    sname=sCookie.getName();
    %>
    <tr><td><%=sname%></td><td><%=svalue%></td></tr>
    <%
    }
    %>
    </table>
    ........(其他内容)
    </body>
    </html>
     
      

  3.   

    你的cookie本身写入的时候是不是已经乱码了 ?
      

  4.   

    已解决,在写入的时候与读出的时候都进行一次转码,
    写入时,
    username = new String(URLEncoder.encode(username, "UTF-8"));
    Cookie coo=new Cookie("user_name",username);
    读出时
    user_name=URLDecoder.decode(coo.getValue(), "UTF-8");