//public Tools(){}
//把数据库中的中文乱码转化成GBK码
public static String toGBKString(String s) {
String str = null;
if (s == null) {
s = "";
}
try {
str = new String(s.getBytes("ISO8859_1"), "GBK");
return str;
}
catch (Exception e) {
return null;
}
}
//把数据库中的中文乱码转化成GBK码
public static String toGBKString(String s) {
String str = null;
if (s == null) {
s = "";
}
try {
str = new String(s.getBytes("ISO8859_1"), "GBK");
return str;
}
catch (Exception e) {
return null;
}
}
如果你在JSP中有参数的传递,如聊天室什么的也有乱码,应该加上一句!
request.setCharacterEncoding("GBK");
用JAVA在网络传递数据时用的是"ISO8859_1"时!
可是我们的中文数据是GBK,或gb2312!
因为RESIN 可以解决。