您的位置:首页 > 其它

web项目中文存储问题

2017-01-12 16:55 148 查看
项目的数据库为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设置


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  web 乱码