本人问题:mysql 保存 blob 类型数据 乱码 解决
未解决,???
之前 private string archiveValue;导致 写入的进去之后的中文 都是乱码
改正后 ,即可
private byte[] archiveValue; // blob
其他解决方法
--------------------------------------------------------------------------------------------------------------------------------
字符串乱码解决
1. new String ( str .getBytes("iso8859-1","utf-8"));
2.
3.mysql my.ini
[mysql]
max_allowed_packet=500M
default-character-set=utf8
[mysqld]
character-set-server=utf8
[client]
default-character-set = utf8
[mysql]
default-character-set = utf8
4.数据库
url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8
username=root
password=root
有人说 url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8
5.过滤器
encodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
forceEncoding
false
encodingFilter
/*
6.添加@RequestMapping注解,配置produces的值
@RequestMapping(value = "/add", produces = {"application/json;charset=UTF-8"})
@RequestMapping(value = "/add", params = {"callback"}, produces = {"text/javascript;charset=UTF-8"})
7. tomcat server.xml
8. eclipse
9.
application/octet-stream;charset=ISO-8859-1
attachment;fileName="${fileName}"
downloadFile
10.sql
CREATE DATABASE `db`
CHARACTER SET 'utf8'
COLLATE 'utf8_general_ci';
11.
12.
HttpServletResponse response = null;
response = ServletActionContext.getResponse();
request.setCharacterEncoding(”utf-8″);
response.setContentType(”text/html;charset=utf-8″);
捐助开发者
在兴趣的驱动下,写一个免费的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(右上角的爱心标志,支持支付宝和PayPal捐助),没钱捧个人场,谢谢各位。
谢谢您的赞助,我会做的更好!