web项目中文存储问题

来源:互联网 发布:厦门java培训多少钱 编辑:程序博客网 时间:2024/05/29 13:47
项目的数据库为MySQL5.5 web服务器为tomcat8.0 服务器为centos7.0
一、中文存入数据库为乱码
常用的设置编码的地方
1、页面上设置编码
 jsp页面:
<%@ page contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true" language="java" %>
html页面:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
2、服务器及程序设置
web.xml设置

tomcat的server.xml设置
<Connector port="8080"  protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />
centos7.0系统编码设置
系统编码查看 locale  
系统编码设置 vi /etc/locale.conf
3、数据编码设置
数据库编码查看 show variables like '%char%'
数据表编码查看  show create table  tableName;
将除了filesystem外的编码均设置为UTF8
二、中文存入数据库为???
此为数据库编码设置不全为UTF8导致
在服务器上通过命令 /etc/my.cnf设置
0 0
原创粉丝点击