数据库配置:
[ mysql] default-character-set=gb2312
[ mysqld] default-character-set=gb2312
数据表: create table table_name(.....)default character set gb2312;过滤器:
public void doFilter(.......)
{
request.setCharacterEncoding("gb2312");
response.setCharacterEncoding("gb2312");
chain.doFilter(request,response);
}
在web.xml中:
<filter> ......<filter-mapping>......页面:
<%@ page contentType="text/html;charset=gb2312" %>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />问题:从JSP页面添加到数据库中的内容乱码,但直接从mysql命令行插入的中文可以正常返回JSP页面.
求解分析.
[ mysql] default-character-set=gb2312
[ mysqld] default-character-set=gb2312
数据表: create table table_name(.....)default character set gb2312;过滤器:
public void doFilter(.......)
{
request.setCharacterEncoding("gb2312");
response.setCharacterEncoding("gb2312");
chain.doFilter(request,response);
}
在web.xml中:
<filter> ......<filter-mapping>......页面:
<%@ page contentType="text/html;charset=gb2312" %>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />问题:从JSP页面添加到数据库中的内容乱码,但直接从mysql命令行插入的中文可以正常返回JSP页面.
求解分析.
2。你的编码格式不对。换成UTF—8试试
谢谢,请问:
1,Post提交有什么不妥?
2,只是将页面的编码换成UTF-8还是所有的都换成UTF-8?
呵呵,真的感谢,原来我一直以为默认的提交方式是Post,就没写,真的出在这里,加上Post就OK了.