我从表单取得字段"目的地(distination):济南"
  String distination =request.getParameter("distination");
然后进行数据库查询:
   select sendname from  address where addressname = distination;
  最后显示
  <%=sendname%>时是乱码
   该如何转换编码方式呢?望指教!

解决方案 »

  1.   

    我从表单取得字段"目的地(distination):济南"
      String distination =request.getParameter("distination");
      byte[] tmp = distination.getBytes("ISO8859-1");
      distination = new String(tmp,"GBK");
    然后进行数据库查询:
       select sendname from  address where addressname = distination;
      最后显示
      <%=sendname%>时是乱码
       该如何转换编码方式呢?望指教!
      

  2.   

    正好反了, 提交到数据库的编码应该是ISO
    从数据库出来的编码应该再由ISO --- GBK
      

  3.   

    給你個最簡單的  distination = new String (request.getParameter("distination").getBytes("iso-8859-1"));
    不管用可以找我
      

  4.   

    从数据库出来的编码如何由ISO--GBK?望指教!
      

  5.   

    String distination =request.getParameter("distination");
      byte[] tmp = distination.getBytes("ISO8859-1");
      distination = new String(tmp,"GBK");
    然后进行数据库查询:
       select sendname from  address where addressname = distination;
      最后显示
       String sendname = rs.getString("sendname").trim().equals("");
       tmp = sendname.getBytes("ISO8859-1");
       sendname = new String(tmp,"GBK");
      <%=sendname%>时是乱码
      

  6.   

    String sendname = rs.getString("sendname").trim().equals("");
       tmp = sendname.getBytes("ISO8859-1");
       sendname = new String(tmp,"GBK");
      <%=sendname%>时是乱码
    并不需要进行代码中文转化处理
    你看下数据库中你要取出来的数据是否是中文正常显示在数据库中