JSP小程序。出现了??

zbwork000 2008-12-02 10:03:57
代码如下:

post1.htm:
<%@ page language="java" %>
<%@ page contentType="text ml;charset=GB2312" import="java.util.*"%>

<html>

<head>

<title>欢迎您的进入!</title>

</head>

<body bgcolor="cyan" text="GREEN" link="yellow" alink ="purple" vlink="red" >
<FONT size="10" >
</FONT>
<br><br><br><br><br>
<CENTER><B>
<FORM ACTION="post1.jsp" method=post name=form >
<p>您的姓名:<INPUT type=text name=txt SIZE=30></p>
<p>您的生日:<INPUT type=text name=bt SIZE=30></p>
<p>密码:<INPUT type=password name=pw SIZE=35></p>
<INPUT type=submit value="登录" name=submit1>
<INPUT type=RESET value="重置" name=reset1>
</FORM>
</B><CENTER>
</body>
<html>

post1.jsp:

<%@ page contentType="text/html; charset=gb2312" %>
<html>
<head>
<title>POST</title>
</head>
<body>
<center><b>
<font size=5 color=blue>post方法的应用
<hr><br>
</font>
<p></p>
<font size=4 color=blue>
姓名<%= request.getParameter("txt")%><br>
请记住你的登录密码:
<br><br>
生日<%=request.getParameter("bt")%><br>
<font color=red>
密码<%= request.getParameter("pw")%>
</font></font>
</b></center>
</body>
</html>

运行时如果输入中文就出现???
这是什么问题啊!!谢谢了。
...全文
57 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zbwork000 2008-12-02
  • 打赏
  • 举报
回复
太谢谢各位了。两种方法都对。
zou_wei_forever 2008-12-02
  • 打赏
  • 举报
回复
post1.jsp:

<%@ page contentType="text/html; charset=gb2312" %>
<html>
<head>
<title>POST </title>
</head>
<body>
<center> <b>
<font size=5 color=blue>post方法的应用
<hr> <br>
</font>
<p> </p>
<font size=4 color=blue>
<%request.setCharacterEncoding("GB2312");%>姓名 <%= request.getParameter("txt")%> <br>
请记住你的登录密码:
<br> <br>
生日 <%=request.getParameter("bt")%> <br>
<font color=red>
密码 <%= request.getParameter("pw")%>
</font> </font>
</b> </center>
</body>
</html>
加上红色部分
tiger868686 2008-12-02
  • 打赏
  • 举报
回复
后面几个同上
tiger868686 2008-12-02
  • 打赏
  • 举报
回复
编码不一致问题所致

解决方案:
<%= request.getParameter("txt")%>

改成<%= new String(request.getParameter("txt").getBytes("iso-8859-1"),"gb2312")%>

试试

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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