7。中文乱码 
在Tomcat中加入<%@ page contentType="text/html;charset=gb2312" %> 
在Reisin中要加入<%@ page contentType="text/html;charset=gb2312" %> 
并且在连接数据库时使用: 
Conn=DriverManager.getConnection("jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=gb2312","root",""); 
关键是?useUnicode=true&characterEncoding=gb2312

解决方案 »

  1.   

    谢谢回复
    <%@ page contentType="text/html;charset=gb2312" %>这句话我加了,数据库我用的是SQLserver2000,不是mySQL,应该不是这个问题
      

  2.   

    程序2  login1.jsp
      …………
      
      这里增加 request.setCharasetEncoding("UTF-8");
      String name=request.getParameter("username");
      out.println("default:"+name);
      

  3.   

    我试了一下,换成jakarta-tomcat-4.0.3是可以的程序2中的  name=new String(name.getBytes("ISO-8859-1"),"GB2312");
      out.println("GB2312:"+name);
      
    输出的是正确的中文,难道是jakarta-tomcat-4.1.18不支持中文参数传递??
      

  4.   

    不会的! jakarta-tomcat-4.1.18 怎么会不支持中文参数传递呢? 我的就可以的
      

  5.   

    icecloud(冰云)你好,你说的方法我也试了,也不行,都是???
    我不明白的就是为什么同一个程序在4.0.3下就可以,而在4.1.18下就乱码?
      

  6.   

    response.sendRedirect("login1.jsp?username="+username);
    这里有问题!
    应该用
    username = URLEncoder.encode( username, "UTF-8" );
    response.sendRedirect("login1.jsp?username="+username);
      

  7.   

    在第2个页面头加上:
    String cBytes = "GBK";
    request.setCharacterEncoding(cBytes);然后在
    String name=request.getParameter("username");
      

  8.   

    response.sendRedirect("login1.jsp?username="+username);
    你用url传参数,通常无法还原,因为url通常是以utf-8字符集传递的,你还是最好把它放到session中,然后从session中取吧。
      

  9.   

    在Dreamweaver+JRun的配置中,有一个批处理文件,该批处理文件根据运行的平台选择
    正确的编码。如果该文件没有得到正确运行,则从数据库中读取得数据为乱码。
    假如平台为中文windows,则正确编码为gb2312;
    如果是日文,则编程Shift_JIS。
    说了这么多,什么意思呢?如果在中文windows平台上作JSP程序,而Jsp的编码却
    为Shift_JIS,很显然会出现乱码。
    所以我猜测,是不是在tomcat中也有一个这样的批处理文件或者设置文件,做一些编码的默认设定的呢?
      

  10.   

    response.sendRedirect("login1.jsp?username="+username);
    out.println("login1.jsp?username="+username, 0);
    <%!
    /**
    *set client url to new url 
    *@param secondTime : wait for time to jump
    *eg: 
    String url = "login.jsp?userid=walksing" ;
    out.println(getUrlTo(url, 5)); // 
    out.close(); //must has
    */
    public static String getUrlTo(String url, int secondTime ){
    StringBuffer s = new StringBuffer();
    s.append("<meta http-equiv=\"refresh\" content=\""
     + secondTime + ";url=" + url + "\">");
    return s.toString();
    }
    %>