<%@  page  contentType="text/html;charset=gb2312"%>

解决方案 »

  1.   

    接收的时候这样
    String mCaption=new String(request.getParameter("Caption").getBytes("8859_1"));
      

  2.   

    在jsp的头部加上<%@  page  contentType="text/html;charset=gb2312"%>
    给你一个字符转换函数!你可以写倒类中,重复使用
    /**** 字符集的转换函数 ****/
            // added by baiqing 2003.02.18
            public static String charConvert(String strSource){
                if (strSource == null){
                    return "";
                }
                else{
                    try{
                      //return new String(strSource.getBytes("GB2312"), "ISO-8859-1");
                      String str = new String(strSource.getBytes("ISO-8859-1"), "GB2312");
                      System.out.println(str);
                      return str;
                    }
                    catch (Exception ex){
                      System.out.println(ex.toString());
                      return "";
                    }
                }
            }
      

  3.   

    出不来阿。出不来。不过还是感谢各位大哥。我把代码发上来大家看看。不过用UTF-8编码就可以,不过那样的话IE的编码格式必须的改成UTF-8才可以。
    test.html如下:
    var test='你好';
    var help=window.open("test.jsp?name="+test,"help","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=1200,height=1000");
    test.jsp如下:
    <%@  page  contentType="text/html;charset=gb2312"%>
    <%@ page import="java.io.*" %> 
    <%
    //response.setContentType("text/html;charset=UTF-8");
    //String name = new String(request.getParameter("name").getBytes("8859_1"), "GB2312") ;
    //String name = new String(request.getParameter("name").getBytes("8859_1"), "UTF-8"); 
    //request.setCharacterEncoding("UTF-8");
    //response.setContentType("text/html;charset=UTF-8");
    String name = request.getParameter("name");
    //String str = new String(name.getBytes("ISO-8859-1"), "GB2312");
    String str = new String(name.getBytes("GB2312"), "ISO-8859-1");
    /*if(name != null && name != "")
    out.println("empty");
    byte[] tmpbyte=name.getBytes("ISO8859_1"); 
    String Hi=new String(tmpbyte); 
    name = new String(name.getBytes("ISO8859_1"), "UTF-8");
    */
    out.println(str);
    out.println("yuu succeed!");
    %>
    这些方法我都试过了。
      

  4.   

    简单,如下:
    传递  
    **************  
    <a  href="<%=request.getRequestURL()%>?username=<%=URLEncoder.encode("中文")%>">click</a>  
    *********  
    接收  
    ******  
    String  username=new  String(request.getParameter("username").getBytes("ISO8859_1"),"gb2312");  
    out.println(username);
      

  5.   

    谢谢楼上仁兄,但是由于某种原因,传递的页面只能是html文件,不能用jsp的方法。
      

  6.   

    如果只能用html,那么可以用javascript的escapevar help=window.open("test.jsp?name="+escape(test),'','');
      

  7.   

    我试了一下,htm文件如下(没有删节):<script language = javascript>
    var test="我们"
    open("Jsp1.jsp?test=" + test,'','');
    </script>Jsp1.jsp如下:
    <%@ page contentType="text/html; charset=GBK" %>
    <%request.setCharacterEncoding("GBK");%>
    <html>
    <head>
    <title>
    Jsp1
    </title>
    </head>
    <body>
    <h1>
    <%= request.getParameter("test")%>
    </h1>
    </body>
    </html>没有问题啊,挺好的
    我上面说的escape好象用不着
      

  8.   

    其实你们都想复杂了,参数可以通过form用submit提交,就没有中文乱码的问题了。
      

  9.   

    对,用form提交,并使用post方法,中文乱码问题只要在服务器端解决就可以了。
    可能在某些情况下,不方便用form,需要在url上附加参数。
      

  10.   

    org.apache.jasper.JasperException: Unable to compile D:\website\tomcat\work\DEFAULT\examples\test\_1_1.java:74: Method setCharacterEncoding(java.lang.String) not found in interface javax.servlet.http.HttpServletRequest.
                        request.setCharacterEncoding("GBK");楼上凯凯老兄,会不会是我jdk的版本有问题。或者tomcat有问题。
    在这里是不方便用form的。只能在url里面传递。
      

  11.   

    使用java.net.URLEncode.Encode()方法,可以把中文转变成url可以传递的
      

  12.   

    String param = "中文";
    URLEncoder.Encode(param);取出来后用
    URLDecoder.decode(param);解码
      

  13.   

    对,这个方法是在Servlet 2.3 中才加上的,你如果用的是Tomcat 4.*,就可以用这个方法。如果一定要用Tomcat 3.*,那就只能自己转码了。
    如果你用jbuilder,里面就有Tomcat 4.0
      

  14.   

    你在每个jsp头部都加上
    <%@ page contentType="text/html; charset=GBK" %>
    或者
    <%@  page  contentType="text/html;charset=gb2312"%>
    就完全解决了
      

  15.   

    我以往的结论:    Tomcat4.0.3怎么都不行,    现在用4.1.2或以上的版本,以上各位的方法就可以
      

  16.   

    soloxiao() :
    可我一直用的是Tomcat 4.0.3 啊,中文问题一直是这样解决的。
      

  17.   

    谢谢楼上的各位兄太!问题现在已经解决,我的版本是tomcat3.3的。jdk1.3的。现在把解决方法公布如下:供大家参考,帖子过两天就结。回答问题的统统有分
    test.htm
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <script language="JavaScript">
    var test = "例子";
    //var test1 = escape(test);
    alert(encodeURIComponent(test));window.open("test.jsp?select="+encodeURIComponent(test),'','');</script>
    <body>
    </body>
    </html>test.jsp:
    <%@ page contentType="text/html;charset=gb2312"%>
    <%@ page import="java.awt.*" %>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*"%>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><body >
    <div align="left">查询结果: 
      <%
    boolean bFlag=true;
    String sPoint ="";
    byte[] bTemp;
    sPoint =  request.getParameter("select");
    if(sPoint!=null)
    {
    bTemp=request.getParameter("select").getBytes("ISO8859_1");
    sPoint= new String(bTemp,"UTF-8");
    }
    out.println(sPoint);
    %>
    </div>
    </body>
    </html>