Apache Tomcat 的默认编码是ISO8859-1,在与数据库联系时,需要转变一下。
加 new String( 字段.getBytes("ISO8859_1"),"gb2312") 就可以了。
试试看。
加 new String( 字段.getBytes("ISO8859_1"),"gb2312") 就可以了。
试试看。
解决方案 »
- myeclipse,tomcat配置问题
- 有没有这种写法?关于<s:if>和<option>,SOS
- 大家帮忙啊,select * from user_table where username='高红岩'在MYSQL中出错了,
- 我在做tapestry时,在resin上发布完成以后,启动服务报下面的异常
- 很棘手的js传值问题
- servlet新手问题,请大大们指教,很简单地,小弟谢过
- 如何用jsp得到访问用户的ip地址?
- 我没有分了
- 怎样在JSP中用户注册时生成一个12位的随机数,和一个随机密码?
- 关于strust中BeanUtils.copyProperties(),在线等!!
- java servlet里怎样调用连接数据库的bean?
- 天啦,我的apache
String sConnStr="jdbc:mysql://localhost/test?user=xxx&password=yyy&useUnicode=true&characterEncoding=8859_1";
public String getStr(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("ISO8859_1");
String temp=new String(temp_t);
return temp;
}
catch(Exception e)
{ return "null";}
}
//从向数据库中提取中文 public String getStr1(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("GBK");
String temp=new String(temp_t,"ISO8859_1");
return temp;
}
catch(Exception e)
{ return "null";}
}
}
http://www2.ccw.com.cn/02/0224/c/0224c05_4.asp