Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java EE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 如何解决jsp输出汉字效果不同的问题
deepblue1979



发贴: 0
积分: 0
于 2003-03-05 21:35 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我用request.getParameter()方法取得参数后
在jsp文件中输出时未能正常输出汉字,而在jsp文件中
其它的汉字却可以正常输出汉字,不知为什么,
请各位大虾指教。

我在ie 的地址栏里输入
http://127.0.0.1:8080/forum/helloworld.jsp?title=中国

附源代码及结果
源代码:
<%@ page import="java.util.*" %>
<%@ page contentType="text/html;charset=gb2312" %>
<%
  String title=null;
  title=(String)request.getParameter("title");
%>
<html>
<head>
  <title>jsp ----------HelloWorld---------显示时间</title>
</head>
<body>
<h1>Hello World</h1>
时间 is:
<%
Date date =new Date();
out.println(date);
%>
<br>
<%=title%><br>
时间
</body>
</html>

输出结果:
Hello World
时间 is: Fri Jan 24 07:31:11 CST 2003
???ú
时间



作者 Re:如何解决jsp输出汉字效果不同的问题 [Re:deepblue1979]
atsmile



发贴: 0
积分: 0
于 2003-03-06 13:32 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
JAVA在网络传输中使用的编码是"ISO-8859-1",故在输出时需要进行转化,如:
String str="中文";
str=new String(str.getBytes("GB2312"),"8859_1");




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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