navicat中文乱码
来源:
章小熊熊
2017-05-28
在测试category那一章 用rest client提交addcategory后 在navicat里查找的记录categoryname为乱码 为检查了my.cnf 与下载的my.cnf一致 后来mysql client 项目分别添加了default-character-set=utf8 重启mysql后登陆 检查show variables like char% 见到相关字符集都为utf8 重新在restclient里插入 依然中文乱码 请问该如何解决?
7回答
-
章小熊熊
提问者
2017-05-28
可以了,谢谢老师,的确是我自己不够仔细。
在听课时,只在虚拟服务器上配置了tomcat,而现在联调是本机,所以tomcat的server.xml没有配置uriencoding。
现在配上,就正常了。
另外再问一下,server.xml里修改的是8080的那一个标签,可idea里配置的tomcat是8088,这样也能生效吗?
012017-05-29 -
章小熊熊
提问者
2017-05-28
我记得没跳 我只跳了window下实操的 我返回去查一下
00 -
Geely
2017-05-28
9成是这个原因,你是不是跳视频了?~~~
00 -
Geely
2017-05-28
是不是tomcat的没有配置URIEncoding?
00 -
章小熊熊
提问者
2017-05-28
在浏览器的地址栏直接输入
localhost:8088/manage/category/add_category.do?parentId=0&categoryName=新增的家用电器
检查数据库依然是录入了乱码。
目前看来与navicatrestclient无关应该是某个我不知道的地方配置错误了
检查虚拟机上的mysql版本select @@version5.1.73我是按视频一步一步装的应该没问题
my.cnf是按照learning.happymmall.com下载的并且怕乱码还添加了mysql和client的字符集设置。
最后是datasource的配置也是直接copy过来的
db.driverLocation=/Users/jane/Downloads/mysql-connector-java-5.1.6-bin.jar
db.driverClassName=com.mysql.jdbc.Driver
db.url=jdbc:mysql://192.168.0.168:3306/mmall_learning?characterEncoding=utf-8
db.username=mmall
db.password=mmall网上有些说要添加什么useUnicode=true我觉得没用处暂时没改
最后贴上tomcat里的日志请各位帮忙看看
[13:42:27.336][DEBUG][org.mybatis.spring.SqlSessionUtils][http-bio-8088-exec-4] Creating a new SqlSession
[13:42:27.336][DEBUG][org.mybatis.spring.SqlSessionUtils][http-bio-8088-exec-4] SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6c4d6a] was not registered for synchronization because synchronization is not active
[13:42:27.337][DEBUG][o.m.s.t.SpringManagedTransaction][http-bio-8088-exec-4] JDBC Connection [jdbc:mysql://192.168.0.168:3306/mmall_learning?characterEncoding=utf8, UserName=mmall@192.168.0.9, MySQL-AB JDBC Driver] will not be managed by Spring
[13:42:27.337][DEBUG][com.mmall.dao.UserMapper.selectLogin][http-bio-8088-exec-4] ==> Preparing: SELECT id, username, password, email, phone, question, answer, role, create_time, update_time from mmall_user where username = ? and password = ?
[13:42:27.337][DEBUG][com.mmall.dao.UserMapper.selectLogin][http-bio-8088-exec-4] ==> Parameters: admin(String), B706835DE79A2B4E80506F582AF3676A(String)
[13:42:27.340][DEBUG][com.mmall.dao.UserMapper.selectLogin][http-bio-8088-exec-4] <== Total: 1
[13:42:27.340][DEBUG][org.mybatis.spring.SqlSessionUtils][http-bio-8088-exec-4] Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6c4d6a]
[13:43:00.409][DEBUG][org.mybatis.spring.SqlSessionUtils][http-bio-8088-exec-6] Creating a new SqlSession
[13:43:00.409][DEBUG][org.mybatis.spring.SqlSessionUtils][http-bio-8088-exec-6] SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1503e6b] was not registered for synchronization because synchronization is not active
[13:43:00.410][DEBUG][o.m.s.t.SpringManagedTransaction][http-bio-8088-exec-6] JDBC Connection [jdbc:mysql://192.168.0.168:3306/mmall_learning?characterEncoding=utf8, UserName=mmall@192.168.0.9, MySQL-AB JDBC Driver] will not be managed by Spring
[13:43:00.410][DEBUG][com.mmall.dao.CategoryMapper.insert][http-bio-8088-exec-6] ==> Preparing: insert into mmall_category (id, parent_id, name, status, sort_order, create_time, update_time) values (?, ?, ?, ?, ?, now(), now())
[13:43:00.411][DEBUG][com.mmall.dao.CategoryMapper.insert][http-bio-8088-exec-6] ==> Parameters: null, 0(Integer), æ°å¢çå®¶ç¨çµå¨(String), true(Boolean), null
[13:43:00.421][DEBUG][com.mmall.dao.CategoryMapper.insert][http-bio-8088-exec-6] <== Updates: 1
[13:43:00.422][DEBUG][org.mybatis.spring.SqlSessionUtils][http-bio-8088-exec-6] Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1503e6b]
日志里写的就是乱码不知道是不是与JDBC Driver] will not be managed by Spring有关
我不太熟悉spring各位看看还要贴上什么配置文件
最后再次感谢老师感谢各位积极为我解惑的同学
00 -
章小熊熊
提问者
2017-05-28
放到浏览器里发送get请求也是乱码
00 -
Geely
2017-05-28
hi 同学,目前请确认mysql等版本是否和课程一致,配置是否和课程一致,然后就是db连接的串是否和代码一致。还有请把具体你的各种配置都放上来,给你看看哈~排查一下哈。另外这个乱码和restlet没关系,正常走接口也是乱码么?
00
相似问题