时间:2021-07-01 10:21:17 帮助过:22人阅读
<!-- 编码格式拦截器 --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <async-supported>true</async-supported> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
这样可以确保,页面的数据传入到controller不会乱码;如果还是乱码,就应该考虑数据库层面的问题了
url:jdbc:mysql://localhost:3306/blog-qwc?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
数据库属性支持:utf8 -- UTF-8 Unicode
数据库排序规则:utf8_general_ci
alter table blog default character set utf8;
// 将该表中的每一列的字符集都改为utf-8
alter table blog change title title varchar(100) character set utf8; alter table blog change author author varchar(100) character set utf8; alter table blog change md md varchar(500) character set utf8; alter table blog change html html varchar(500) character set utf8;
注:alter table blog change html html varchar(500) character set utf8; 字段html要写两遍,没有毛病
修改db.properties文件中的url:
url:jdbc:mysql://localhost:3306/blog-qwc?useUnicode=true&characterEncoding=UTF-8;zeroDateTimeBehavior=convertToNull;allowMultiQueries=true
修改为:
url:jdbc:mysql://localhost:3306/blog-qwc?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
修改内容:& ==》 &
这也是没办法的办法了
springmvc+mybatis+mysql 数据库插入中文是乱码
标签:删除数据库 info 字段 har span 技术分享 编码 syn localhost