就是那个减号“-” 用紫光输入法输入(按Shift键)是“——”在MySQL5.0中是显示“——”。<%=new String(str.getBytes("ISO8859-1")) %> 却显示成俩问号“??”

解决方案 »

  1.   

    用GBK或GB2312,字体就会正确显示了,
      

  2.   

    但是用GBK或GB2312 就都变成????了 -_-!!~
      

  3.   

    你的这种情况与你的TOMCAT版本有关.
      

  4.   

    apache-tomcat-5.5.17.exe  Tomcat改改设置能不能好呢?JSP文件往MySQL5.0写入数据不用转换,没一个乱码。要是从数据库读出来的汉字或别的页面传过来的汉字必须<%=new String(str.getBytes("ISO8859-1")) %>才能正常显示。
      

  5.   

    是的,存入数据库和从数据库里取出来用<%=new String(str.getBytes("ISO8859-1")) %>转换就没问题了,能正常显示,与TOMCAT无关,但如果在URL即地址栏传递中文你怎么转都会有问题的,因为与TOMCAT版本有关.
      

  6.   

    String a=request.getParamter("aaa","ISO_8859_1");
      

  7.   

    String a=request.getParamter("aaa","ISO_8859_1");
    ================================================================两个参数不行。An error occurred at line: 10 in the jsp file: /bbs/test2.jsp
    Generated servlet error:
    The method getParameter(String) in the type ServletRequest is not applicable for the arguments (String, String)
      

  8.   

    现在如果在JSP文件中加入<% request.setCharacterEncoding("gb2312"); %> 则可以正确显示另一个网页传递的“——”。
    用<% request.setCharacterEncoding("gbk"); %>则也不能正确显示“——”(汉字可以正确显示了)。现在数据库读取仍然不能正确显示。用“.getBytes("gb2312")”全部字符都是乱码,用.getBytes("ISO8859-1")就“——”乱码。
      

  9.   

    问题在这里解决了:http://community.csdn.net/Expert/topic/4764/4764555.xml?temp=.2270624
    (yangmowei(薇薇) ( ) 信誉:100    Blog  strName=new String(strName.getBytes("GB2312"),"iso8859-1");)=====================================================================
    我的写法跟她的不一样。
    =new String(str.getBytes("iso8859-1"),"GB2312");意思是,把MySQL读出来的iso8859-1编码的字符以GB2312编码赋给新建的字符串?。谢谢大家,谢谢yangmowei。散分.....