当前位置: 技术问答>java相关
还是中文问题,救急
来源: 互联网 发布时间:2015-10-30
本文导语: 都是在turbo linux 6.0 + Iplanet 4.1的环境下,不同的是一个是jdk1.3,一个是jdk1.4.1,几条简单的jsp语句: 为啥在jdk1.3下中文可以正常显示,jdk1.4.1下中文全显示为??各位高手帮帮忙,急需答案啊。 | ...
都是在turbo linux 6.0 + Iplanet 4.1的环境下,不同的是一个是jdk1.3,一个是jdk1.4.1,几条简单的jsp语句:
为啥在jdk1.3下中文可以正常显示,jdk1.4.1下中文全显示为??各位高手帮帮忙,急需答案啊。
为啥在jdk1.3下中文可以正常显示,jdk1.4.1下中文全显示为??各位高手帮帮忙,急需答案啊。
|
针对jsp和servlet:
解决办法:
第一:
在jsp页面加入:
或者在servlet里面
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=gb2312");//这是重要的
上面的如果在不行就用如下的方法在数据入库前进行调用:
public static String UnicodeToChinese(String s){
try{
if(s==null||s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("ISO8859_1"),"gb2312");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}
public static String ChineseToUnicode(String s){
try{
if(s==null||s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("gb2312"),"ISO8859_1");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}
3:)解决weblogic/webshpere中文问题:
在web.xml文件中需要配置中文环境。r如下:
weblogic.httpd.inputCharset./*
GB2312
解决办法:
第一:
在jsp页面加入:
或者在servlet里面
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=gb2312");//这是重要的
上面的如果在不行就用如下的方法在数据入库前进行调用:
public static String UnicodeToChinese(String s){
try{
if(s==null||s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("ISO8859_1"),"gb2312");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}
public static String ChineseToUnicode(String s){
try{
if(s==null||s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("gb2312"),"ISO8859_1");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}
3:)解决weblogic/webshpere中文问题:
在web.xml文件中需要配置中文环境。r如下:
weblogic.httpd.inputCharset./*
GB2312
|
能先转化一下吗?然后再显示!!
|
试一下
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。