在開頭加:
<%@ page contentType="text/html;charset=gb2312"%>

解决方案 »

  1.   

    你在提交的时候贾上这么一句
    String str="...";
    String str=new String(str.getBytes("iso-8859-1"),"GBK");
    然后再向数据库提交
      

  2.   

    你在提交的时候贾上这么一句
    String str="...";
    String str=new String(str.getBytes("ISO8859-1");
    然后再向数据库提交 
      

  3.   

    在開頭加:
    <%@ page contentType="text/html;charset=gb2312"%>
    写入数据库时对字符串
    new String((yourchars.getBytes("GBK"),"ISO8859_1");
    读出数据库的字符串时
    new String((databasechars.getBytes("ISO8859_1"),"GBK");
      

  4.   

    谢谢大家
    我用的是resion<%@ page contentType="text/html;charset=gb2312"%> 
    我一直加着
    也用你们说的方法做了
    还是没有结果!!郁闷
      

  5.   


    left.jsp
    <%@ include file="data.jsp"%>
    <table>
    <tr>
    <td>
    <% Rst=Stmt.executequery('select *from type order by type_order_id");
    while(Rst.next())
    {
    String type_id=Rst.getString("type_id");
    //String type_name=Rst.getString("type_name");
    //String type_name=new String(Rst.getBytes("type_name"),"GB2312");
    String type_name=new String((Rst.getString("type_name")).getBytes(),"GBK");
    %>
    <a href="music.jsp?type=<%=type_id%>"><%=type_name"%></a>.....<br>
    <%
    }
    %>
    </td>
    <tr>
    <table>结果能出来,但是是?????
      

  6.   


    我用的是SQL server
    数据能显示出来,
    但是只能是英文的
    中文都显示为:??????
      

  7.   

    我现在不在家里所以无法调试;String name1=request.getParameter("name");
            name1=new String(name1.getBytes("8859_1"));
    您看下面我可以改成:
    .....................................................
    String name1=Rst.getString("name");
            name1=new String(name1.getBytes("8859_1"));
      

  8.   

    我没看到你的left.jsp
    有<%@ page contentType="text/html;charset=gb2312"%> 
    这一段嘛
      

  9.   

    不要告诉我你把它包含在<%@ include file="data.jsp"%>里了,如果是的话,把它写在你的left.jsp中
      

  10.   

    1.<%@ page contentType="text/html;charset=GBK"%>
    2.从SQLServer中读取记录需要进行下面的字符转换吗?你直接输出看看
    //String type_name=new String(Rst.getBytes("type_name"),"GB2312");
    String type_name=new String((Rst.getString("type_name")).getBytes(),"GBK");
      

  11.   

    使用这个方法进行转换试试public String getStr(String str1){
      try{
        return new String(str1.getBytes("ISO-8859-1"),"GBK"); 
      }
      catch(Exception e){
        System.out.println(e);
        return null;
      }
    }
      

  12.   

    谢谢大家了,这个中文问题我昨晚已经做出来了.(:
    String type_name=new String(Rst.getString("type_name").getBytes("GBK"),"ISO8859_1");
     另外还有几中方法转换.
    Thanks!!(:
      

  13.   

    回复人: dengmj(重庆森林) (  ) 信誉:100  2002-4-16 14:53:02  得分:0  
     
     
      在開頭加:
    <%@ page contentType="text/html;charset=gb2312"%>
    写入数据库时对字符串
    new String((yourchars.getBytes("GBK"),"ISO8859_1");
    读出数据库的字符串时
    new String((databasechars.getBytes("ISO8859_1"),"GBK"); 
     
     
    恰好写反了!应该是:
    写入数据库的字符串时
    new String((databasechars.getBytes("ISO8859_1"),"GBK"); 
    读出数据库时对字符串
    new String((yourchars.getBytes("GBK"),"ISO8859_1");