重新建立数据表。
值得注意的地方是:applicationContext.xml中的数据库连接必须设置为
2、在进行数据保存之前进行gb2312到iso8859-1编码的转换,数据?寥≈?笤僮?还?础?
这时的applicationContext.xml中的数据库连接必须设置为
它们相同的地方是在用jsp进行中文内容填加时,都要进行gb2312到iso8859-1编码的转换:
String name;
name=trans(request.getParameter("name"));
String trans(String chi)
{
String result = null;
byte temp [];
try
{
temp=chi.getBytes("iso-8859-1");
result = new String(temp);
}
catch(java.io.UnsupportedEncodingException e)
{
System.out.println (e.toString());
}
return result;
}
String trans(Object chi)
{
return trans(chi.toString());
}
编码问题,分段一步步查吧,
1.从前台页面提交后台是否乱码;如果是则是项目在编码阶段就有问题,
2.提交到数据库之前是否乱码,如果不是,则数据的默认编码格式有问题
最好都修改到utf-8啥都没有问题
设置下编码格式就行