有关JSP中中文显示的问题,在线等待高手回答,急!!! 在jsp程序的第一行加入:<%@page contentType="text/html;charset=gb2312"%> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用getBytes("iso-8859-1"),"gb2312"试试。应该是编码的问题。 给你一个函数:/**** 字符集的转换函数 ****/ // added by baiqing 2003.02.18 public static String charConvert(String strSource){ if (strSource == null){ return ""; } else{ try{ //return new String(strSource.getBytes("GB2312"), "ISO-8859-1"); String str = new String(strSource.getBytes("iso-8859-1"), "GB2312"); System.out.println(str); return str; } catch (Exception ex){ System.out.println(ex.toString()); return ""; } } } 可以通过servlet filter的方式(一般像tomcat的应用程序服务器用的是iso-8859-1编 码) 在tomcat目录下/wepapps/examples/WEB-INF/classes/filters有一个文件SetCharacte rEncodingFilter.class copy到你的classes/filters目录下 再在web.xml加上 <filter> <filter-name>Set Character Encoding</filter-name> <filter-class>filters.SetCharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>gb2312</param-value> </init-param> </filter> 以后就不用在jsp中转码了!至于jsp显示中文的方法是在你的jsp页面的顶端加上如下语句: <%@ page contentType="text/html;charset=gb2312" %> 和 <META http-equiv="Content-Type" content="text/html;charset=gb2312"> 楼上的,我找不到这个类文件,能不能将你的SetCharacterEncodingFilter.class发到 登录的一个小难点 一个jsp页面为什么能同时响应多个请求 JPA比较罕见的应用,谁能解决? flex开发电子地图 Tomcat6下面的webapps如何发布到WebSphere下? 在JSP中,我怎么把“2005-01-01”转换成“2005年01月01日” 是否可出现滚动条 请问什么服务器能发布中文名的jsp页啊? 大侠请进,关于servlet的。 如何通过jdbc连接SQL server2000?各位高手快帮帮忙! ◆现在大家都使用什么测试管理软件?◆ 请教
getBytes("iso-8859-1"),"gb2312"
试试。
应该是编码的问题。
/**** 字符集的转换函数 ****/
// added by baiqing 2003.02.18
public static String charConvert(String strSource){
if (strSource == null){
return "";
}
else{
try{
//return new String(strSource.getBytes("GB2312"), "ISO-8859-1");
String str = new String(strSource.getBytes("iso-8859-1"), "GB2312");
System.out.println(str);
return str;
}
catch (Exception ex){
System.out.println(ex.toString());
return "";
}
}
}