跑错地方了吧,这里是pb哦。不过北京希望电子出版社出版的《用JSP轻松开发Web网站》中第四章有一节及第七章一部分就是专门讨论jsp中文显示问题的,你可以看看。大致意思是向数据库写入中文时:
1、先用getStr(string name)进行内码转换。
2、更新数据库时使用PrepareStatement对象。给你复制一段例程:
<%
preparedStatement prestmt=NULL
//..........
if(boolcanpost==true)
{
try
{
strSQL="insert into table(col1,col2......)values(?,?,...)";
prestmt=conn.preparestatement(strSQL);
prestmt.setBytes(1,col1.getBytes("GBK"));
prestmt.setBytes(1,col2.getBytes("GBK"));
...........................
prestmt.executeUpdate();
}
catch(exception de)
{
system.err.print("de.executeQuery:"+de.getmessage());
}
//.........
%>
1、先用getStr(string name)进行内码转换。
2、更新数据库时使用PrepareStatement对象。给你复制一段例程:
<%
preparedStatement prestmt=NULL
//..........
if(boolcanpost==true)
{
try
{
strSQL="insert into table(col1,col2......)values(?,?,...)";
prestmt=conn.preparestatement(strSQL);
prestmt.setBytes(1,col1.getBytes("GBK"));
prestmt.setBytes(1,col2.getBytes("GBK"));
...........................
prestmt.executeUpdate();
}
catch(exception de)
{
system.err.print("de.executeQuery:"+de.getmessage());
}
//.........
%>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货