没有转换,可以有两种办法解决,一个是在录入的JSP页面里添加下面的代码
<%@ page language="java" contentType="text/html; charset=GB2312"%>
或者是
在你得到数据后把数据转换一下
String strvalue = new String(strvalue.getBytes("ISO8859_1"),"GB2312");
strvalue 表示你得到的数据。

解决方案 »

  1.   

    确保数据库使用中文字符集,如 eucgb, utf8, cp936
      

  2.   

    public String convertStr(String str) {
        String newstr = str;
        try {
          newstr = new String(str.getBytes("ISO-8859-1"));
        }
        catch (UnsupportedEncodingException uee) {
          System.err.println("convert error!");
        }
        return newstr;
      }插入数据前对string调用convertStr(string),取数据rs.getString不需要转换~直接就能在网页上显示中文
      

  3.   

    谢谢你angelheart() ,也谢谢大家。
    我的问题解决了,我总结一下,贴出来再结贴。^_^
    我发现现在很多人老是问同一个问题,很多人在提出一个问题后,得到解决方法就OK了。
    我们自己在一个问题上走了很多弯路,为什么不让我们的兄弟姐妹少走些弯路呢。
      

  4.   

    如果是从JSP页面向数据库中添加中文记录,在每个值之前,通过以下代码转换一下,就可以不经过转换直接读出中文(同配置情况下):
    <%! public String convertStr(String str) {
        String newstr = str;
        try {
          newstr = new String(str.getBytes("ISO-8859-1"));
        }
        catch (UnsupportedEncodingException uee) {
          System.err.println("convert error!");
        }
        return newstr;
      }
    %>如果是不同浏览器之间的传递中文参数,可通过以下代码转换再可读出中文:
    <% request.setCharacterEncoding("gb2312"); %><%! String trans(String chi)
    {    byte[] temp;
         String result = null;
            try
        {   temp=chi.getBytes("ISO-8859-1");
                 result=new String(temp,"GB2312");
        }
            catch(UnsupportedEncodingException e)
            {
             System.out.println (e.toString());
            }
    return result;
    }
    %>
    例如:<%= trans(request.getParameter("Uname")) %>