Topic: jsp中文显示的问题有解决办法了吗?我试了前辈说的但是没用,求救!!!

  Print this page

1.jsp中文显示的问题有解决办法了吗?我试了前辈说的但是没用,求救!!! Copy to clipboard
Posted by: wdlfellow
Posted on: 2004-08-24 11:25

jsp中文显示的问题有解决办法了吗?我试了前辈说的但是没用,求救!!!

2.Re:jsp中文显示的问题有解决办法了吗?我试了前辈说的但是没用,求救!!! [Re: wdlfellow] Copy to clipboard
Posted by: zcs_75
Posted on: 2004-08-25 11:00

<%@ page contentType="text/html;charset=gb2312"%>

3.Re:jsp中文显示的问题有解决办法了吗?我试了前辈说的但是没用,求救!!! [Re: wdlfellow] Copy to clipboard
Posted by: 周轻舟
Posted on: 2004-08-31 10:21

<%@ page contentType="text/html;charset=gb2312"%>

这个在tomcat的默认配置下肯定无法正确显示中文

4.Re:jsp中文显示的问题有解决办法了吗?我试了前辈说的但是没用,求救!!! [Re: wdlfellow] Copy to clipboard
Posted by: bluedest
Posted on: 2004-09-01 10:58

<%@ page contentType="text/html; charset=GBK" %>
<% request.setCharacterEncoding("gb2312");%>

这两句话我用在不能显中文的页面里,好像还没有失手过,你试试吧

5.Re:jsp中文显示的问题有解决办法了吗?我试了前辈说的但是没用,求救!!! [Re: wdlfellow] Copy to clipboard
Posted by: samuelxp
Posted on: 2004-09-01 14:00

<%@ page pageRequest="UTF-8" %>

页面直接用UTF-8写。

还有可以用JSTL
<fmt:message key="xxx"/>

basename 为message的话
要有message_zh_CN.properties,文件用GB写,然后用navtive2ascii.exe转成unicode的数字代码替换。

6.Re:jsp中文显示的问题有解决办法了吗?我试了前辈说的但是没用,求救!!! [Re: wdlfellow] Copy to clipboard
Posted by: 周轻舟
Posted on: 2004-09-02 11:21

在JSP页面中试试JSTL的<fmt:requestEncoding value="gb2312"/>
在servlet中用request.setCharacterEncoding("gb2312");

最好在web.xml中配置filter

7.Re:jsp中文显示的问题有解决办法了吗?我试了前辈说的但是没用,求救!!! [Re: wdlfellow] Copy to clipboard
Posted by: rebirth
Posted on: 2004-09-02 17:03

关于转码问题,贴个简单的类上来方便使用。
public class CHARSET
{

public CHARSET()
{
}

public static String ISO2GBK(String s)
throws Exception
{
if(s == null || s.trim().equals(""))
{
return "";
} else
{
String s1 = new String(s.getBytes("ISO-8859-1"), "GBK");
return s1;
}
}

public static String ISO2GB2312(String s)
throws Exception
{
if(s == null || s.trim().equals(""))
{
return "";
} else
{
String s1 = new String(s.getBytes("ISO-8859-1"), "GB2312");
return s1;
}
}

public static String ISO2BIG5(String s)
throws Exception
{
if(s == null || s.trim().equals(""))
{
return s;
} else
{
String s1 = new String(s.getBytes("ISO-8859-1"), "BIG5");
return s1;
}
}

public static String GBK2ISO(String s)
throws Exception
{
if(s == null || s.trim().equals(""))
{
return s;
} else
{
String s1 = new String(s.getBytes("GBK"), "ISO-8859-1");
return s1;
}
}

public static String GB23122ISO(String s)
throws Exception
{
if(s == null || s.trim().equals(""))
{
return s;
} else
{
String s1 = new String(s.getBytes("GB2312"), "ISO-8859-1");
return s1;
}
}

public static String BIG52ISO(String s)
throws Exception
{
if(s == null || s.trim().equals(""))
{
return s;
} else
{
String s1 = new String(s.getBytes("BIG5"), "ISO-8859-1");
return s1;
}
}

public static String GBK2BIG5(String s)
throws Exception
{
if(s == null || s.trim().equals(""))
{
return s;
} else
{
String s1 = ISO2BIG5(GBK2ISO(s));
return s1;
}
}

public static String GB23122BIG5(String s)
throws Exception
{
if(s == null || s.trim().equals(""))
{
return s;
} else
{
String s1 = ISO2BIG5(GB23122ISO(s));
return s1;
}
}
}

8.Re:jsp中文显示的问题有解决办法了吗?我试了前辈说的但是没用,求救!!! [Re: wdlfellow] Copy to clipboard
Posted by: ming500
Posted on: 2004-09-15 18:46

好东西 啊

9.Re:rebirth [Re: wdlfellow] Copy to clipboard
Posted by: sunzy19810705
Posted on: 2004-09-16 08:47

谢谢大哥,真的是个不错的javabean,珍藏哦!谢谢!


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923