重定向问题请各位进来看看!

jhg127 2004-08-13 02:06:46
Example3_13.jsp:
<%@ page contentType="text/html;charset=GB2312" %>
<HTML>
<BODY bgcolor=gray>
<P>填写姓名:<BR>
<FORM action="tree4.jsp" method="get" name=form>
<INPUT TYPE="text" name="boy">
<INPUT TYPE="submit" value="Enter">
</FORM>
</BODY>
</HTML>
tree4.jsp:
<%@ page contentType="text/html;charset=GB2312" %>
<HTML>
<BODY>
<% String str=null;
str=request.getParameter("boy");
if(str==null)
{str="";
}
byte b[]=str.getBytes("ISO-8859-1");
str=new String(b);
if(str.equals(""))
  { response.sendRedirect("Example3_13.jsp");
 }
else
 {out.print("欢迎您来到本网页!");
 out.print("str");
 }
%>
</BODY>
</HTML>
运行后得到下列错误:
有五处错误:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\Myfile\tree4_jsp.java:49: illegal character: \12288
?? { response.sendRedirect("Example3_13.jsp");
Generated servlet error:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\Myfile\tree4_jsp.java:50: illegal character: \12288
??}
^
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\_\org\apache\jsp\Myfile\tree4_jsp.java:52: illegal character: \12288
??{out.print("娆㈣??ㄦ??版?缃?〉锛?");
^
请大家帮帮看看,谢谢!
...全文
126 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
vvfish119 2004-08-13
  • 打赏
  • 举报
回复
if(str.equals(""))
{ response.sendRedirect("Example3_13.jsp");
}
看到这句没有??
里面的response.sendRedirect("Example3_13.jsp"); 前面有个空格,把它删除就好了
power17 2004-08-13
  • 打赏
  • 举报
回复
请求页面:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<table width="50%" border="1" align="center">
<tr>
<td><form name="form1" method="post" action="get.jsp">
<div align="center">
<p>name:
<input name="name" type="text" id="name">
</p>
<p>pass:
<input name="pass" type="text" id="pass">
</p>
<p>qq:
<input name="qq" type="text" id="qq">
</p>
<p>
<input type="submit" name="Submit" value="提交">
</p>
</div>
</form></td>
</tr>
</table>
</body>
</html>


以下将其显示出来:

get.jsp

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>

<%
String name=new String(request.getParameter("name").getBytes("ISO-8859-1"));
String pwd=request.getParameter("pass");
String qq=request.getParameter("qq");
out.println(name);
out.println(pwd);
out.println(qq);

%>

</body>
</html>


贴出来给高手指点。刚学jsp没几天。什么都不懂。看完sun的开发文档瞎凑的。

知道写的不规范,但又不知道怎么改。

高手指点
高手指点
高手指点
高手指点
高手指点
高手指点
高手指点
高手指点
高手指点
高手指点

谢谢了
power17 2004-08-13
  • 打赏
  • 举报
回复
我中 qq 里面回答的算不算?

我是这样解决的,而且试过了,可以通过的

request.getParameter("para").getBytes("ISO-8859-1")

huangk 2004-08-13
  • 打赏
  • 举报
回复

byte b[]=str.getBytes("ISO-8859-1");
str=new String(b);

改为:

str = new String(str.getBytes("ISO-8859-1"),"GB2312");
gln 2004-08-13
  • 打赏
  • 举报
回复
你的jsp文件里好像有非法的字符,所以它编译的时候出错

81,092

社区成员

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

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