如果数据库能正常显示的话,通常不需要任何转换就可以打印出来
当然也可能是jdbc存在问题,如果是这样建议更换jdbc驱动
还可能是web服务器和操作系统的问题,那我就不是很清楚了。

解决方案 »

  1.   

    给你个方法吧
    package com.yangjun.struts.code;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; 


    }
    在jsp页面中用useBean实现
    如:<jsp:useBean id="code" class="com.yangjun.struts.code.CharCode"/>
        <%=code.UnicodeToChinese(rs.getString(2))%>
      

  2.   

    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
      

  3.   

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

  4.   

    <%@ page contentType="text/html;charset=GBK" %>
    等加到jsp页的顶部。
    ok
    ^_^
      

  5.   

    public static final String toChinese(String strVal)
        {
            try
            {
                if (strVal == null)
                {
                    return "";
                }
                else
                {
                    strVal = strVal.trim();
                    strVal = new String(strVal.getBytes("ISO8859_1"), "GBK");
                    return strVal;
                }
            }
            catch (Exception exp)
            {
                return "";
            }
        }
    /**
         * 将数据从数据库中取出后转换,将字符串由“GBK”转换为“ISO8859_1”
         *
         * @param strVal 要转换的字符串
         * @return 从“GBK”到“ISO8859_1”得到的字符串
         */
        public static final String toISO(String strVal)
        {
            try
            {
                if (strVal == null)
                {
                    return "";
                }
                else
                {
                    strVal = new String(strVal.getBytes("GBK"), "ISO8859_1");
                    return strVal;
                }
            }
            catch (Exception exp)
            {
                return "";
            }
        }<%@ page contentType="text/html;charset=ISO8859_1"%>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    或者
    <%@ page contentType="text/html;charset=gb2312"%>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
      

  6.   

    <%@ page contentType="text/html;charset=gb2312"%>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    最有效了
    如果按你那么说的话,你数据库里应该就是乱码了
      

  7.   

    1,在oracal中显示的数据一切正常。
    说明你的oracl目前使用的编码支持中文。
    2,jsp页面显示中文时出现乱码。
    因为java使用的是unicode编码,你要变换后放
    到jsp页面上。
      

  8.   

    rainshow说得有道理,其他的请仔细看问题。
      

  9.   

    请问thinkerhj(hjzxy) 如何变换??
      

  10.   

    <% request.setCharacterEncoding("GB2312"); %>
    把上面语句加到你JSP页面的第一行就可以了。
      

  11.   

    <%@ page contentType="text/html;Charset=gb2312" %>
    其中Charset的第一个字符大写,试试看。祝成功!呵呵
      

  12.   

    request.setCharacterEncoding("GB2312");这个正解
      

  13.   

    request.setCharacterEncoding("GB2312");
    <%@ page contentType="text/html;Charset=gb2312" %>
    <%@ page contentType="text/html;Charset=GBK" %>
    都试过了,不行。
    有没有其他方法??
    给思路就给分了!!
      

  14.   

    用filter吧,参照tomcat下的example里的filter类和web.xml配置文件,不过web.xml和jsp上的编码方式要想同.
      

  15.   

    request.setCharacterEncoding("gb2312");
    在你要接受变量的前面加上上面那一句,还要记得在jsp页面最上面加上一句:
    <%@ page contentType="text/html;Charset=GBK" %>
      

  16.   

    <% request.setCharacterEncoding("GB2312"); %>