Home  >  Article  >  Database  >  tomcat 中文乱码, mysql 中文乱码_MySQL

tomcat 中文乱码, mysql 中文乱码_MySQL

WBOY
WBOYOriginal
2016-06-01 13:11:181105browse

Tomcat

tomcat中文乱码 get 请求.

修改server.xml中的添加URIEncoding='UTF-8'

<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding='UTF-8' />

tomcat中文乱码 post 版

另外HttpURLConnection上传参数的时候要转码成url编码

outStream.writeBytes("&" + URLEncoder.encode(key, "utf-8") + "=" + URLEncoder.encode(value, "utf-8"));

mysql 中文乱码

修改 my.cnf ,在 [mysqld] 下面添加

character-set-server = utf8

创建数据库的时候制定编码格式为 utf-8

CREATE DATABASE dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

或者修改已有数据库/表编码格式为 utf-8

ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci;ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn