解决Linux下Tomcat向MySQL插入数据中文乱码问题
一、问题
在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
更多相关文章
- android中文api(89)——ViewManager
- Android(安卓)中文API(86)——ResourceCursorAdapter
- Android中文API(144) —— JsonWriter
- android 中文api (62) —— ViewSwitcher.ViewFactory
- android api 中文 (74)—— AdapterView.AdapterContextMenuInfo
- Android(安卓)中文 API (27) —— SeekBar.OnSeekBarChangeListene
- [RK3399][Android7.1] 调试笔记 --- 设置搜狗为开机默认输入法
- Android(安卓)中文 API (35) —— ImageSwitcher
- Android(安卓)中文 SDK (47) —— Filter