首先同一采用utf-8
1.数据库属性改为utf-8 必要时更改mysql的配置文件: default-character-set=utf8 character-set-server=utf8
2.连接数据库:jdbc:mysql://localhost:3306/db_bug?useUnicode=true&characterEncoding=utf8
3.request中文乱码: get请求的编码方式为:ISO-8859-1 doGet方法:例子:String spotName=new String(request.getParameter(“spotName”).getBytes(“ISO-8859-1”),“UTF-8”); doPost方法:request.setCharacterEncoding(“UTF-8”);
4.response中文乱码:response.setCharacterEncoding(“UTF-8”);