你jsp段是不是加了
<meta http-equiv="Content-Type" content="text/html; charset='gb2312'>
这样的语句,
这样语句的功能会帮你自动再做一次转化,就会错误
<meta http-equiv="Content-Type" content="text/html; charset='gb2312'>
这样的语句,
这样语句的功能会帮你自动再做一次转化,就会错误
解决方案 »
- unknown oracle majoy version[0]
- 如何进行大规模并发处理
- 怎么判断一个网站能不能打得开?
- width,height为多少px时,A4纸打印时刚好一页
- struts多图片上传的问题
- 怎么让jsp弹出对话框?
- 如何实现操作后弹出确认窗口??
- 关于linux下面用formValidator框架进行中文用户名验证乱码,求高手,在线等,解决了100全部奉上,要200也可以
- JCreator如何 debug
- 为什么jsp访问mysql数据库时第一次打开正常,再刷新就读不到数据了?
- jsp传值问题
- jsp更新sqlserver2000时出错java.sql.datatruncation:data truncation 请帮忙,在线等
这会从数据库里取的是中文了,但在整个页面上显示的全都是乱码了
if (str == null) {
return str;
}
try {
str = new String(str.getBytes("ISO8859_1"), "gb2312");
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
读出来的时候不需修改。
页面最顶端加:
<%@ page contentType="text/html; charset=GBK" %>
屡试不爽
{
if ((pstrWord != null) && (!pstrWord.equals("")))
{
pstrWord = new String(pstrWord.getBytes("ISO8859_1"), "GBK");
return pstrWord;
}
return "";
}
public static String toReChinese(String pstrWord) throws java.io.UnsupportedEncodingException
{
if ((pstrWord != null) && (!pstrWord.equals("")))
{
pstrWord = new String(pstrWord.getBytes("GBK"), "ISO8859_1");
return pstrWord;
}
return "";
}
用这两个方法试试,其中一个肯定行,要用到时调用一下就行了