解决Linux下Tomcat向MySQL插入数据中文乱码问题
作者:Qiu_CJ 时间:2024-01-29 13:06:36
一、问题
在windows上面使用eclipse开发的项目在windows上面运行一切正常,部署到腾讯云时出现向MySQL数据库中插入数据是中文乱码
二、解决办法
1、尝试一
直接在linux上面使用insert语句插入中文,正常
2、尝试二
在tomcat配置文件server.xml中加入useBodyEncodingForURI="true",不行
3、尝试三
在tomcat配置文件server.xml中再加入URIEncoding="UTF-8",不行
4、尝试四
由于是SSM框架项目,在web.xml中加过过滤器
<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>
不行
5、尝试五
在mybatis配置文件的jdbc路径后面加上?characterEncoding=utf-8,成功!
修改后的jdbc访问路径为:
jdbc:mysql://localhost:3306/daad?characterEncoding=utf-8
来源:http://blog.51cto.com/doublelinux/2097532
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python程序员鲜为人知但你应该知道的17个问题
Vue elementUI 自定义表单模板组件功能实现
![](https://img.aspxhome.com/file/2023/2/139742_0s.png)
python爬取微信公众号文章的方法
![](https://img.aspxhome.com/file/2023/9/135079_0s.jpg)
关于Python使用turtle库画任意图的问题
SQL中where语句的用法及实例代码(条件查询)
SQL Server 数据库基本操作语句总结
mysql 8.0.11安装配置方法图文教程
![](https://img.aspxhome.com/file/2023/7/77217_0s.jpg)
自动化测试读写64位操作系统的注册表
![](https://img.aspxhome.com/file/2023/3/125453_0s.png)
Go语言框架快速集成限流中间件详解
Golang轻量级IoC容器安装使用示例
Python如何使用print()函数输出格式化字符串
![](https://img.aspxhome.com/file/2023/5/86345_0s.png)
python图像常规操作
![](https://img.aspxhome.com/file/2023/0/83760_0s.jpg)
新手必备Python开发环境搭建教程
![](https://img.aspxhome.com/file/2023/6/109366_0s.png)
python 定义函数 返回值只取其中一个的实现
![](https://img.aspxhome.com/file/2023/4/96914_0s.png)
php filter协议使用方法
![](https://img.aspxhome.com/file/2023/5/55335_0s.png)
浅谈如何使用Python控制手机(一)
![](https://img.aspxhome.com/file/2023/9/68979_0s.jpg)
Mysql DDL常见操作汇总
vue3获取当前路由地址
![](https://img.aspxhome.com/file/2023/6/126546_0s.jpg)
使用url_helper简化Python中Django框架的url配置教程
详解mysql 获取某个时间段每一天、每一个小时的统计数据
![](https://img.aspxhome.com/file/2023/4/113974_0s.jpg)