补充说明:
我修改的是jsp网站的页面

解决方案 »

  1.   

    在网页的开始加上:
    <%@ page contentType="text/html;charset=gb2312"%>
    试一试
      

  2.   

    编码转换一下
    页面
    <%@ page contentType="text/html;charset=GB2312" %> 
    String str=request.getParameter("name");
    String aa = new String(str.getBytes("ISO8859_1"),"GB2312");设置request字符集
    request.setCharacterEncoding("gb2312");
    设置数据编码保持一致就不会乱码
      

  3.   

    public String getISOFromGBK(String str)throws Exception{
        String str1=null;
        try{
          str1 = new String(str.getBytes("gb2312"), "ISO-8859-1");
          return str1;
        }catch(UnsupportedEncodingException e){
          throw new Exception("getISOFromGBK"+e.toString() );
        }
    从数据库中读取后用这个方法转换一下,试一试  }
      

  4.   

    解决办法:  
    第一:  
     1:在jsp页面加入:  
    <%@  page  contentType="text/html;  charset=gb2312"  %>  
     2:在servlet里面:  
       public  void  doGet(HttpServletRequest  request,  HttpServletResponse  response)  throws  ServletException,  IOException  {  
           response.setContentType("text/html;  charset=gb2312");//这是重要的  
     
    3:上面的如果在不行就用如下的方法在数据入库前进行调用:  
    public  static  String  UnicodeToChinese(String  s){  
       try{  
             if(s==null  &brvbar;  &brvbar;s.equals(""))  return  "";  
             String  newstring=null;  
             newstring=new  String(s.getBytes("ISO8859_1"),"gb2312");  
             return  newstring;  
           }  
       catch(UnsupportedEncodingException  e)  
       {  
       return  s;  
       }  
       }  
     
    public  static  String  ChineseToUnicode(String  s){  
       try{  
       if(s==null  &brvbar;  &brvbar;s.equals(""))  return  "";  
       String  newstring=null;  
       newstring=new  String(s.getBytes("gb2312"),"ISO8859_1");  
         return  newstring;  
       }  
       catch(UnsupportedEncodingException  e)  
       {  
       return  s;  
     }  
       }
      

  5.   

    我也遇到了这个问题,将数据库的备份导入数据库后,从数据库中读取的中文内容都显示正常,重器机子后从数据库中读取的中文内容都变成问号。上面的方法都试过,统统都不行。
    我的系统配置:
    redhat8.0
    httpd-2.0.45.tar.gz
    resin-2.1.9.tar.gz
    j2sdk-1_4_1_02-linux-i586.bin
    mysql-4.0.13.tar.gz
    mm.mysql-2.0.4-bin.jar
      

  6.   

    编码转换的bean:/*下面是一个写好的BEAN~~~
    *使用它,你可以进行UNICODE和GBK之间的方便转换
    *比如:参数传递、入库等等
    */
    package com.db;import java.lang.*;
    import java.util.*;
    import java.lang.Integer;
    import java.sql.*;public class CharCode{public static String UnicodeToChinese(String s){ 
    try{ 
    if(s==null||s.equals("")) return ""; 
    String newstring=null; 
    newstring=new String(s.getBytes("ISO8859_1"),"gb2312"); 
    return newstring; 

    catch(Exception e) 

    return s; 

    } public static String ChineseToUnicode(String s){ 
    try{ 
    if(s==null||s.equals("")) return ""; 
    String newstring=null; 
    newstring=new String(s.getBytes("gb2312"),"ISO8859_1"); 
    return newstring; 

    catch(Exception e) 

    return s; 


    }//使用BEAN你应该没有问题吧?
    //我的BEAN放在com.db中
    //可以这样使用
    //<jsp:useBean id="code" class="com.db.CharCode"/>
    //String name=code.UnicodeToChinese((String)request.getParameter("in_name"));
      

  7.   

    除了 hhuzhj(阿金)的方法外还要在数据库连接字符串如下设置:ConnStr="jdbc:mysql://localhost/dbname?useUnicode=true&characterEncoding=ISO-8859-1";我的系统配置:
    redhat8.0
    httpd-2.0.45.tar.gz
    resin-2.1.9.tar.gz
    j2sdk-1_4_1_02-linux-i586.bin
    mysql-4.0.13.tar.gz
    mm.mysql-2.0.4-bin.jar
      

  8.   

    数据库中要用nvarchar保存中文。
      

  9.   

    开头加
    <%@page contentType="text/html; charset=GBK" %>