javaweb中文乱码
请求时乱码:更改server.xml
请求处添加:
request.setCharacterEncoding("utf-8");
服务器添加:URlEncoding="utf-8"
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URlEncoding="utf-8"/>
响应乱码(页面显示)
在out前添加:
//设置响应编码
response.setContentType("text/html; charset=UTF-8");
response.setCharacterEncoding("utf-8");
数据库乱码
命令行:
ALTER TABLE `user`.`client`
CHANGE `uname` `uname` VARCHAR(30) CHARSET utf8 COLLATE utf8_general_ci NULL,
CHANGE `upassword` `upassword` VARCHAR(32) CHARSET utf8 COLLATE utf8_general_ci NULL;
ALTER TABLE `user`.`client`
CHARSET=utf8, COLLATE=utf8_bin;
SQLyog:
连接数据库方式:
String URL="jdbc:mysql://localhost:3306/studentmanagement?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8";