Home > Database > Mysql Tutorial > tomcat 中文乱码, mysql 中文乱码_MySQL

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

WBOY
Release: 2016-06-01 13:11:18
Original
1138 people have browsed it

Tomcat

tomcat中文乱码 get 请求.

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

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

tomcat中文乱码 post 版

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

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

mysql 中文乱码

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

character-set-server = utf8
Copy after login

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

CREATE DATABASE dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Copy after login

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

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


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template