本人问题:mysql 保存 blob 类型数据 乱码 解决
未解决,???
之前 private string archiveValue; 导致 写入的进去之后的中文 都是乱码
改正后 ,即可
private byte[] archiveValue; // blob
其他解决方法
http://knight-black-bob.iteye.com/blog/2213090
--------------------------------------------------------------------------------------------------------------------------------
字符串乱码解决
1. new String ( str .getBytes("iso8859-1","utf-8"));
2.<%@ page contentType="text/html; charset=UTF-8"%>
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.过滤器
<filter> <filter-name>encodingFilter</filter-name> <filter-class> org.springframework.web.filter.CharacterEncodingFilter </filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>false</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
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
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8"/>
8. eclipse
9.
<action name="showOverAllXls" class="showOverAllDataAction" method="doXLS"> <result name="success" type="stream"> <param name="contentType"> application/octet-stream;charset=ISO-8859-1 </param> <param name="contentDisposition">attachment;fileName="${fileName}"</param> <param name="inputName">downloadFile</param> </result> </action>
10.sql
CREATE DATABASE `db` CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';
11.
<constant name="struts.i18n.encoding" value="utf-8" />
12.
HttpServletResponse response = null; response = ServletActionContext.getResponse(); request.setCharacterEncoding(”utf-8″); response.setContentType(”text/html;charset=utf-8″);