Tomcat4+JSP+mysql无法显示中文!!!急!急!急!

lanse89 2004-03-29 09:20:42
我在上面所示的环境下面,不能显示数据库中的中文。请各位大侠帮忙了。
...全文
49 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zwxu 2004-03-29
  • 打赏
  • 举报
回复
用<%@ page contentType="text/html;charset="GBK" %>比较好些
Robotyea 2004-03-29
  • 打赏
  • 举报
回复

String str = new String(str.getBytes("ISO-8859-1"), "gb2312");

就是字符编码格式问题,保你好用
mq612 2004-03-29
  • 打赏
  • 举报
回复
再加入代码:<%request.setCharacterEncoding("gb2312");%>
banni2003 2004-03-29
  • 打赏
  • 举报
回复
对每一个从数据库中提取的数据进行转换
<%!
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";
}
%>
runtoflower 2004-03-29
  • 打赏
  • 举报
回复
string改成String
runtoflower 2004-03-29
  • 打赏
  • 举报
回复
加上这一句<%@ page contentType="text/html;charset=gb2312" %>
lanse89 2004-03-29
  • 打赏
  • 举报
回复
大哥你说的办法怎么不行?报错啊!我刚转来用JSP请多指教了。
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.


An error occurred between lines: 5 and 18 in the jsp file: /test/mytest.jsp

Generated servlet error:
C:\tomcat4\work\Standalone\localhost\_\test\mytest$jsp.java:72: Class org.apache.jsp.string not found.
string db =new string(rs.getValue("Title")).getBytes("8859-1");
^


An error occurred between lines: 5 and 18 in the jsp file: /test/mytest.jsp

Generated servlet error:
C:\tomcat4\work\Standalone\localhost\_\test\mytest$jsp.java:72: Class org.apache.jsp.string not found.
string db =new string(rs.getValue("Title")).getBytes("8859-1");
^


An error occurred between lines: 5 and 18 in the jsp file: /test/mytest.jsp

Generated servlet error:
C:\tomcat4\work\Standalone\localhost\_\test\mytest$jsp.java:74: Undefined variable: title
out.print(s+"<br>结果"+title+"<BR>");
^
3 errors, 1 warning
zl_xue 2004-03-29
  • 打赏
  • 举报
回复
string db =new string(rs.getValue("db")).getBytes("8859-1")
lanse89 2004-03-29
  • 打赏
  • 举报
回复
在此谢谢各位。我的问题已经解决了。我用的下面的方法:
String s=new String((rs.getString("Title").getBytes("iso8859-1")));

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧