本人问题: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″);
捐助开发者
在兴趣的驱动下,写一个免费
的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(右上角的爱心标志,支持支付宝和PayPal捐助),没钱捧个人场,谢谢各位。
谢谢您的赞助,我会做的更好!