日期:2014-05-18  浏览次数:20782 次

====郁闷了,再次遇到传说中的中文乱码问题,有点怪,不是平常页面的那种====
怪了,
用Statement直接构造好sql语句插入的时间就不会又乱码,一切正常,
但是在换了
PreparedStatement   pst   =   conn.prepareStatement(sql);
pst.setString(1, "中文中文 ");
这样的入库的时候,变成乱码勒,

别说从页面过来的时候用getByte直接转换,
我现在是直接输入中文都变乱码,
没有任何传值的操作,也就不存在说在request的时候乱码问题,
奇怪勒,杂回事?在另一个项目里面这样做就没任何问题,

mssqlserver2000
tomcat6



------解决方案--------------------
或者在你的Bean中处理一下,你看看哪个好用。
public String getApplication () throws UnsupportedEncodingException {
//post=request.getParameter( "keywords ").getBytes( "8859_1 ");
String postName=this.hrDemandAccept.getPostName();
//String postName= " ";
if(postName!=null&&!postName.equals( " ")&&!postName.equals( "null ")){
String temp=new String(postName.getBytes( "ISO8859_1 "), "gb2312 ");
hrDemandAccept.setPostName(temp);
}
//String temp=new String(postName.getBytes( "ISO8859_1 "), "SHIFT-JIS ");
//hrDemandAccept.setPostName(temp);
return SUCCESS;
}