乱码问题

大家好:我的本地系统是WindowXP,服务器是Tomcate6,
系统在本地机器,读取Oracle10G数据库中Blog字段时候,在JSP页面显示正常,将其发布到服务器上时,页面中Blob字段显示出现中文乱码问题,页面设置编码为UTF-8,且Blob字段在显示前,后台已经转化成String类型字符串,请问这算怎么回事?

问题出在这里:
public String getBlobValue(Blob blob) {
StringBuilder sb = new StringBuilder();
InputStream is = null;
try {
if (blob != null) {
is = blob.getBinaryStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = is.read(buffer)) != -1) {
sb.append(new String(buffer, 0, len));
}
}
} catch(Exception e) {
e.printStackTrace();
} finally {
try {
is.close();
}catch(Exception e) {
e.printStackTrace();
}
}
return sb.toString();
}

这是我从数据库中取出blob类型数据并转化为字符串,转完之后就是乱码,期待解决的方法

posted on 2011-08-12 18:06  想飞的小丑鱼  阅读(182)  评论(0编辑  收藏  举报

导航