如果数据库里是乱码在写数据库前用以下方法转换一下:
public static String iso8859togbk(String strvalue)
{
try{
if(strvalue==null)
return null;
else
{
strvalue = new String(strvalue.getBytes("ISO8859_1"), "GBK");
return strvalue;
}
}catch(Exception e){
return null;
}
} public static String iso8859togb2312(String strvalue)
{
try{
if(strvalue==null)
return null;
else
{
strvalue = new String(strvalue.getBytes("ISO8859_1"), "gb2312");
return strvalue;
}
}catch(Exception e){
return null;
}
} public static String gb2312to8859(String strvalue)
{
try{
if(strvalue==null)
return null;
else
{
strvalue = new String(strvalue.getBytes("gb2312"), "ISO8859_1");
return strvalue;
}
}catch(Exception e){
return null;
}
}
public static String gbkto8859(String strvalue)
{
try{
if(strvalue==null)
return null;
else
{
strvalue = new String(strvalue.getBytes("gbk"), "ISO8859_1");
return strvalue;
}
}catch(Exception e){
return null;
}
}
public static String iso8859togbk(String strvalue)
{
try{
if(strvalue==null)
return null;
else
{
strvalue = new String(strvalue.getBytes("ISO8859_1"), "GBK");
return strvalue;
}
}catch(Exception e){
return null;
}
} public static String iso8859togb2312(String strvalue)
{
try{
if(strvalue==null)
return null;
else
{
strvalue = new String(strvalue.getBytes("ISO8859_1"), "gb2312");
return strvalue;
}
}catch(Exception e){
return null;
}
} public static String gb2312to8859(String strvalue)
{
try{
if(strvalue==null)
return null;
else
{
strvalue = new String(strvalue.getBytes("gb2312"), "ISO8859_1");
return strvalue;
}
}catch(Exception e){
return null;
}
}
public static String gbkto8859(String strvalue)
{
try{
if(strvalue==null)
return null;
else
{
strvalue = new String(strvalue.getBytes("gbk"), "ISO8859_1");
return strvalue;
}
}catch(Exception e){
return null;
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货