temp=new String(temp.getBytes("ISO8859_1"),"GB2312");
错误语句,temp还没有new出来,哪来的getBytes?
String temp;
temp=new String(oldtemp.getBytes("ISO8859_1"),"GB2312");oldtemp是要处理的String.

解决方案 »

  1.   

    这些变量的定义,我当然是做了,UnsupportedEncodingException 的意思是说我作为参数传进去的"ISO8859_1"和"GB2312"找不到对应的Encoding,所以就不能转化。我不知道如何配置才能找到这些Encoding,还是我的JBuilder7本身有问题。
      

  2.   

    <%@ page contentType="text/html;charset=gb2312"%>
     加这一段怎么样?
      

  3.   

    看这里,希望对你有帮助!
    http://www.jspserver.com:8080/cgi-bin/jspbbs/topic.cgi?forum=3&topic=3&show=
      

  4.   

    我也使用jbuilder7,不用配置,下面是我的代码你参考一下
    String tempStr1=new String((request.getParameter("ParaName")).getBytes("ISO8859-1"),"gb2312");
      

  5.   

    谢谢,大家,看来我用的方法是对的,但是我的机器可能有问题,因为我让它执行   
     System.out.println(request.getCharacterEncoding());
    打出来的,竟然是null。
    不知道为什么request的getCharacterEncoding()返回的会是空?
      

  6.   

    有个java.???.*你没有加,
    是什么忘了
    import
      

  7.   

    <%!
    public String chStr(String str)
    {  String temp_p=str;
       byte[] temp_t=temp_p.getBytes("ISO8859-1");
       String temp=new String(temp_t);
       return temp;
    }
    %>
      

  8.   

    通过在JBuilder7里面的逐行调试,发现了一个错误,就是报告Can not locate RequestFacade.java from project source/class path,我想,是否就是这个错误让我的JBuilder7抛出UnsupportedEncodingException?
      

  9.   

    文字编码转换可以在页面中print出来看看是不是乱码
    试一试这个函数
    public String getChinese(String str){
    try{
    String str1=str;
    byte[] str2=str1.getBytes("ISO8859-1");
                String temp=str2.toString();
    return temp;
    }
    catch(Exception e)
    {
    }
    return "Null";
    }