数据乱码问提,请高手帮忙!!!!!!!!!!急啊!!!!!!!!!!!!!!!!!!!!!!! 统一编码UNIX的oracle要写入之前转码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 试一试下面这段代码public String iso2gb(String qs) { try{ if (qs == null) return "NULL"; else { return new String(qs.getBytes("iso-8859-1"),"gb2312"); } } catch(Exception e){ System.err.println("iso2gb error:"+e.getMessage()); } return "NULL"; } public String gb2iso(String qs) { try { if (qs == null) return "NULL"; else { return new String(qs.getBytes("gb2312"),"iso-8859-1"); } } catch(Exception e){ System.err.println("gb2iso error:"+e.getMessage());} return "NULL"; } 字符存入数据库时用 gb2iso()函数,将字符从数据库取出时,再用 iso2gb()函数。 另,jsp页面的顶部应该加入下面句话: “<%@page contentType="text/html;charset=gb2312"%> ” public class CodeConvert { private String re; public void convert(String externS){ this.re = externS; if(this.re!=null) { try{ this.re = new String(re.getBytes("8859_1"), "GB2312"); } catch(Exception e) { System.out.println("编码转换异常!"); } } } public String getConvert(){ return this.re; }} 我以前出现问题的时候也是用“fokman(傲视红尘)”这种方法解决的。数据读入数据库转一遍,读出的时候在转一遍 同意楼上pioneerzhou(害怕距离) 的,最好在jsp页面中再加一句:<%request.setCharacterEncoding("GBK");%>,这样就准没问题 http://www.regexlab.com/zh/encoding.htm看看这个有帮助 String str = new String(rs.getString("").getBytes(),"GB2312"); 帮我分析下为什么这个javamail程序错误密码也能connect上去 XFire调用service的问题 用JasperReport+iReport+eclipse 做Web报表的实例 急~!! 想写一篇关于Java的核心期刊的文章,不知道如何选题 CMP中DataSource问题 数组查找的问题 关于MySQL的问题 谁用struts做过项目呀?网上有用struts做项目的源码么,谁能提供一份,我想学习。谢谢。 有关JDBc Connection的问题,up 有分 请问用WEBLOGIC配置EJB的事务问题。 JSP如何获取文本框内容 救命啊``Windows2003的DirectX``
public String iso2gb(String qs)
{
try{
if (qs == null) return "NULL";
else
{
return new String(qs.getBytes("iso-8859-1"),"gb2312");
}
}
catch(Exception e){
System.err.println("iso2gb error:"+e.getMessage());
}
return "NULL";
} public String gb2iso(String qs)
{
try
{
if (qs == null) return "NULL";
else {
return new String(qs.getBytes("gb2312"),"iso-8859-1"); }
}
catch(Exception e){ System.err.println("gb2iso error:"+e.getMessage());}
return "NULL";
} 字符存入数据库时用 gb2iso()函数,将字符从数据库取出时,再用 iso2gb()函数。 另,jsp页面的顶部应该加入下面句话:
“<%@page contentType="text/html;charset=gb2312"%> ”
private String re;
public void convert(String externS){
this.re = externS;
if(this.re!=null)
{
try{
this.re = new String(re.getBytes("8859_1"), "GB2312");
}
catch(Exception e)
{
System.out.println("编码转换异常!");
}
}
}
public String getConvert(){
return this.re;
}
}
数据读入数据库转一遍,读出的时候在转一遍
看看这个有帮助