你用什么服务器?如果是tomcat的话,会有这个问题。
数据在存入数据库和取出时要编码:
如下:
<%!
public String getStr(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("GBK");
String temp=new String(temp_t,"ISO8859_1");
return temp;
}
catch(Exception e)
{
 
}
return "null";
}
%> 
String strSQL="SELECT * FROM book where category="+cate+" order by id desc";
ResultSet RSa = workM.executeQuery(strSQL);
getStr(RSa.getString("author"))
这样用一下,就可以了》
你先看看数据库里的数据是不是乱码?

解决方案 »

  1.   

    是中文问题,经常遇到
    要用方法转换,把8859-1码转化为gbk\gb2312码
    String namestr=request.getParamater("name");//得到8859-1码
    String name=new String(name.getBytes("8859-1"),"GBK");//得到gbk码,入库即可
      

  2.   

    1、在页面中加入<%@ page contentType="text/html;charset=gb2312"%>语句。
    2、在建立数据库连接时使用sqlConn=java.sql.DriverManager.getConnection("jdbc:mysql://localhost/database-name?useUnicode=true&characterEncoding=gb2312");注意其中的useUnicode=true&characterEncoding=gb2312。以上是以tomcat4.0和mysql为例。