关于jsp页面插入mysql乱码问题
2015-06-29 15:48
585 查看
从jsp页面插入mysql数据库中文乱码解决
1.检查mysql的默认编码格式(mysql下运行指令:show variables like 'character%'),装载mysql时指定默认编码集
2.jsp页面中设置<META http-equiv=Content-Type content="text/html; charset=utf-8">
3.servlet中设置
response.setContentType("text/html;charset=utf-8");
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
get方式
String str = equest.getParamers("");
str = new String(str.getBytes("IOS8859-1","UTF-8"));
POST请求参数乱码问题
1. Tomacat的 conf下的 server.xml文件中将
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />替换为
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
useBodyEncodingForURI="true"
IEncoding="utf-8"
URIEncoding="utf-8"/>
2. eclipse中 window -->preferences 输入spelling 将Encoding 设置为utf-8
1.检查mysql的默认编码格式(mysql下运行指令:show variables like 'character%'),装载mysql时指定默认编码集
2.jsp页面中设置<META http-equiv=Content-Type content="text/html; charset=utf-8">
3.servlet中设置
response.setContentType("text/html;charset=utf-8");
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
get方式
String str = equest.getParamers("");
str = new String(str.getBytes("IOS8859-1","UTF-8"));
POST请求参数乱码问题
1. Tomacat的 conf下的 server.xml文件中将
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />替换为
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
useBodyEncodingForURI="true"
IEncoding="utf-8"
URIEncoding="utf-8"/>
2. eclipse中 window -->preferences 输入spelling 将Encoding 设置为utf-8
相关文章推荐
- MySQL自增长主键探究
- MySQL学习系列11:触发器
- MySQL row模式binlog复制原理
- MySQL中concat函数
- 用Navicat将SQL Server数据导入mysql
- mysql截取图片url的图片名 更新到新字段
- 57 mysql 导出表结构
- mysql创建索引大全
- Mac下安装Mysql出现 Can’t connect to local MySQL server through socket '/tmp/mysql.sock'
- MySQL查询本周、上周、本月、上个月份数据的sql代码
- mysql数据库5.6 源码安装
- MySQL参数之sql_mode详解
- mysql UNIX时间戳与日期的相互转换
- mysql修改密码
- Mysql表操作
- MySQL常用命令
- 【C/C++学院】(23)Mysql数据库编程--C语言编程实现mysql客户端
- mysql主从 1050错误
- MySQL性能调优my.cnf详解
- 关于MYSQL索引优化和in or替换为union all的问题