首先确信你写入数据库的中文不是乱码。
在需要显示中文的地方用getGB(String)。另外你的数据库操纵语句要利用getISO(String)
public class CodeConver {
public static String getGB(String str) {
try {
if(str == null){
return null;
}
else{
str = str.trim();
String temp = new String(str.getBytes("ISO8859-1"),"GB2312");
return temp;
}
} catch (Exception e) {
return null;
}
}
public static String getISO(String str) {
try {
if(str == null){
return null;
}
else{
str = str.trim();
String temp = new String(str.getBytes("GB2312"),"ISO8859-1");
return temp;
}
} catch (Exception e) {
return null;
}
}
}