new String(xxx.getBytes("ISO8859_1"),"GBK")

解决方案 »

  1.   

    這不單是oracle的問題.在jsp中很多地方都會遇到亂碼問題.
    你用這個函數轉換一下就可以了.
    <%!
    public String TranStrType(String str) throws Exception
    {
    try{ 
    if(str==null) 
    return null; 
    else 

    str = new String(str.getBytes("ISO8859-1")); 
    return str; 

    }catch(Exception e){ 
    return null; 

    }%>
    例子
    <%
    String Str_Name=TranStrType(request.getParameter("name"));
    String Str_Card_id=request.getParameter("Card_id");
    %>
      

  2.   

    To liucm(雪山飞狐) :如果我数据库数据已存在怎么办?
      

  3.   

    liangxuan1979(不贪) : 
    还是不行;
    我用下面的方法:
    System.out.println("打印数据库数据 is:" + TranStrType(rs.getString("name")));‘is:’前是正常的 rs.getString("name")得到的汉字就不正常了  都是“????”
      

  4.   

    如果你数据库中已经存入乱码,又不想删除,可能只能在显示时用str = new String(str.getBytes("ISO8859-1")); 函数再转换一下
      

  5.   

    liucm(雪山飞狐) : 我用lingxuan1979的函数转换了一下  还是不行使用前 汉字显示为:鎶曡瘔寤鸿鏌使用后 汉字显示为:???????
      

  6.   

    jsp开头有这个吗?
    <%@page contentType="text/html;charset=GBK"%>
    如没有加上
      

  7.   

    liucm(雪山飞狐): 我加的是gb2312  GBK也试过 都不行
      

  8.   

    <%@ page contentType="text/html;charset=iso8859_1" %>
    <%@ page contentType="text/html;charset=GBK" %>
    <%@ page contentType="text/html;charset=gb2312" %>
    <meta http-equiv="Content-Type" content="text/html; charset=gb5">
    strvalue = new String(strvalue.getBytes("ISO8859_1"), "GBK"); 
    strvalue = new String(strvalue.getBytes("ISO8859_1"), "gb2312"); 
    strvalue = new String(strvalue.getBytes("gb2312"), "ISO8859_1"); 大概就这几种办法每种方法分别都试一下!