日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql 压缩的blob不能正常显示中文内容_servlet网页显示MySQL BLOB中文乱码

發布時間:2025/3/11 数据库 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 压缩的blob不能正常显示中文内容_servlet网页显示MySQL BLOB中文乱码 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

讀取數據:httpservletrequest.setCharacterEncoding("gb2312");Strings1=httpservletrequest.getParameter("source");byteabyte0[]=s1.getBytes("ISO-8859-1");s2=newString(abyte0)...

讀取數據:

httpservletrequest.setCharacterEncoding("gb2312");

String s1 = httpservletrequest.getParameter("source");

byte abyte0[] = s1.getBytes("ISO-8859-1");

s2 = new String(abyte0);

輸出數據中文就是亂碼

s3 = new String(resultset.getString("source"));

輸出頁面

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是二進制類型直接顯示肯定是亂碼啊

數據庫default-character-set=gb2312其他地方的中文也會變成亂碼

default-character-set=latin1其他地方中文正常顯示

網頁是charset=gb2312,

class文件:httpservletresponse.setContentType("text/html; charset=ISO8859_1");

字段類型是text或者varchar

insert into source_code (solution_id,source) values(?,compress(?))

column charset=atin1

能夠正常顯示繁體簡體中文,英文以及特殊符號

把BLOB換成TEXT類型能正常顯示

//paramHttpServletRequest.setCharacterEncoding("gb2312");

String str3 = paramHttpServletRequest.getParameter("source");

// byte[] arrayOfByte = str2.getBytes("ISO-8859-1");

//String str3 = new String(arrayOfByte);

SQL語句:

insert into source_code (solution_id,source) values(?,compress(?))

改為:

insert into source_code (solution_id,source) values(?,?)

但是原來的數據是用compress壓縮的現在是亂碼了

壓縮text數據又不能正常顯示中文

展開

總結

以上是生活随笔為你收集整理的mysql 压缩的blob不能正常显示中文内容_servlet网页显示MySQL BLOB中文乱码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。