试试转换成iso-8859-1
 str = new String(str.getBytes("utf-8"), "iso-8859-1");

解决方案 »

  1.   

    /**
         *  将UNICODE8编码的字符串转化为GB2312编码。
         *
         *@param  source  Description of the Parameter
         *@return         转换后可在网页上正常显示的字符串。
         */
        public final static String utf8ToGb2312( String source )
        {
            return translate( source, "iso-8859-1", "GBK" );
        }    /**
         *  转化源编码的字符串为目标编码。
         *
         *@param  source          Description of the Parameter
         *@param  sourceCodeset   Description of the Parameter
         *@param  targetCodeset   Description of the Parameter
         *@return                 java.lang.String
         */
        public final static String translate( String source, String sourceCodeset,
                                              String targetCodeset )
        {
            String out;        try
            {
                out = new String( source.getBytes( sourceCodeset ), targetCodeset );
            }
            catch ( Exception ex )
            {
                out = "";
            }        //System.out.println(out);
            return out;
        }
      

  2.   

    to: xue_sharp(小雪) 
      谢谢您的方法,但是好像还是不行。我的目的是这样的:在一个servlet通过getpathinfo()得到传来的url,但是当url中包含中文时,得到的是乱码,其原因可能是大多数用户ie的高级选项中“总是以utf-8发送url”是选择的。所以我认为传来的url是按照utf-8 编码的,但在将utf-8 转换为gb2312时总是出错。
      

  3.   

    那你显示给他们的地址先用encodeURL(),这样他们返回来访问的时候,就可以访问到了。