mysql 乱码解决
数据库
1.创建数据库时启动mysql使用参数(运行->cmd)
(mysql -u root -p --default-character-set utf8)
mysql -uroot;
2.创建数据库
create database xxx default character set utf8;
use xxx;
set names utf8;修改数据库编码
显示数据库编码(show variables like 'character%';)
执行sql脚本
source /home/tarena/phone.sql
3.修改mysql 数据库连接url
jdbc:mysql://localhost:3306/phone?useUnicode=true&characterEncoding=utf8
4.提交时使用post提交
<form action="xxx.do" method="post">
5.使用过滤器filter
reqeust.setCharacterEncoding("utf8");
6.jsp页面设置字符集
<%@page contentType="text/html;charset=utf8" %>