mysql 压缩的blob不能正常显示中文内容_servlet网页显示MySQL BLOB中文乱码
讀取數(shù)據(jù):httpservletrequest.setCharacterEncoding("gb2312");Strings1=httpservletrequest.getParameter("source");byteabyte0[]=s1.getBytes("ISO-8859-1");s2=newString(abyte0)...
讀取數(shù)據(jù):
httpservletrequest.setCharacterEncoding("gb2312");
String s1 = httpservletrequest.getParameter("source");
byte abyte0[] = s1.getBytes("ISO-8859-1");
s2 = new String(abyte0);
輸出數(shù)據(jù)中文就是亂碼
s3 = new String(resultset.getString("source"));
輸出頁(yè)面
httpservletresponse.setContentType("text/html; charset=gb2312");
用這種方式也不行:
InputStream in = resultset.getBinaryStream("source");
byte[] buffer = new byte[1024];
int len = 0;
while ( (len = in.read(buffer)) != -1)
{
s3 += new String(buffer, 0, len);
}
in.close();
其他類型都能正常顯示中文
滿意加高分
text,vchar類型
都是用的gb2312
BLOB是二進(jìn)制類型直接顯示肯定是亂碼啊
數(shù)據(jù)庫(kù)default-character-set=gb2312其他地方的中文也會(huì)變成亂碼
default-character-set=latin1其他地方中文正常顯示
網(wǎng)頁(yè)是charset=gb2312,
class文件:httpservletresponse.setContentType("text/html; charset=ISO8859_1");
字段類型是text或者varchar
insert into source_code (solution_id,source) values(?,compress(?))
column charset=atin1
能夠正常顯示繁體簡(jiǎn)體中文,英文以及特殊符號(hào)
把BLOB換成TEXT類型能正常顯示
//paramHttpServletRequest.setCharacterEncoding("gb2312");
String str3 = paramHttpServletRequest.getParameter("source");
// byte[] arrayOfByte = str2.getBytes("ISO-8859-1");
//String str3 = new String(arrayOfByte);
SQL語(yǔ)句:
insert into source_code (solution_id,source) values(?,compress(?))
改為:
insert into source_code (solution_id,source) values(?,?)
但是原來(lái)的數(shù)據(jù)是用compress壓縮的現(xiàn)在是亂碼了
壓縮text數(shù)據(jù)又不能正常顯示中文
展開(kāi)
總結(jié)
以上是生活随笔為你收集整理的mysql 压缩的blob不能正常显示中文内容_servlet网页显示MySQL BLOB中文乱码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 如何用unit test测试contro
- 下一篇: 织梦 php 传值,php获取post参