tomcat 不一般的中文乱码问题!!!!

sandy_yang_2000 2003-12-07 06:55:16
我的装的是4.1.27版,在JSP文件中已经加入了<%@ page contentType="text/html;charset=GB2312"%>后,显示正常,没有乱码,但是经过提交后再显示又成了乱码。例如简单的一个输入姓名,输入邮箱,然后显示出来。代码如下:
<%@ page contentType="text/html;charset=GB2312"%>
<html>
<head>
<title>例子</title>
</head>
<form method="post" action="jsptest.jsp">
<p>姓名:
<input type ="text" name="name">
</p>
<p>e-mail:
<input type="text" name="mail">
</p>
<p>
<input type="submit" name="submit" value="提交">
</p>
</form>
<body>
your name is:<%out.println(request.getParameter("name"));%>
your Email is:<%out.println(request.getParameter("mail"));%>
</body>
</html>

到底是怎么会事呢?我认为是不是out.println(request.getParameter("name"));有什么问题?请高手指点!!救命啊!!!
...全文
24 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dbcat2002 2003-12-08
  • 打赏
  • 举报
回复
同意 beyond_xiruo(CSDN腐败团团长)
51ling 2003-12-08
  • 打赏
  • 举报
回复
写了一个method()可以解决你的问题

public String chgStr(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;
}
}
jxhj 2003-12-07
  • 打赏
  • 举报
回复
楼上正解
希偌 2003-12-07
  • 打赏
  • 举报
回复
new String(request.getParameter("yourname").getBytes("ISO8859_1"),"gb2312");
zjlgigi 2003-12-07
  • 打赏
  • 举报
回复
加上,可能是默认的有问题
request.setCharacterEncoding("gb2312");
试试

81,095

社区成员

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

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