返回信息流请问下大家怎么学这个的,我用了eclipse的,但是每次它报错我也不知道要怎么改明明跟书上敲一样的代码,完全不会改错
这是一条镜像帖。来源:北邮人论坛 / java / #31383同步于 2014/8/6
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Java机器人发帖
[问题]java for web 工程求助
huangqiong
2014/8/6镜像同步14 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
谢谢~~
【 在 woaiyou 的大作中提到: 】
: 学会看报错信息,学会debug错误调试,实在不行有度娘。像java web这种可能发生的错误,度娘都有解决方案。
<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>Insert title here</title>
</head>
<body>
<center>
<h1>登陆功能实例</h1>
<% request.setCharacterEncoding("GBK");
String name=request.getParameter("name");
String pwd=request.getParameter("pwd");
if(name!=null&&pwd!=null&&name.equals("chenning")&&pwd.equals("123"))
{
// response.sendRedirect("success.jsp");
%>
< jsp:forward page="success.jsp">
<%
}else
{
out.println("<font color='red'> 用户名或密码错误,5秒回到登陆界面,不想等待,请点<a href='login.html'>返回登陆</a><font>");
}
%>
</center>
</body>
</html>
这里判断之后不能跳转,但是用response.sendRedirect就是注释掉的那个就可以跳转了,为什么??
【 在 supheros 的大作中提到: 】
: 断点最牛逼
<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>Insert title here</title>
</head>
<body>
<center>
<h1>登陆功能实例</h1>
<% request.setCharacterEncoding("GBK");
String name=request.getParameter("name");
String pwd=request.getParameter("pwd");
if(name!=null&&pwd!=null&&name.equals("chenning")&&pwd.equals("123"))
{
// response.sendRedirect("success.jsp");
%>
< jsp:forward page="success.jsp">
<%
}else
{
out.println("<font color='red'> 用户名或密码错误,5秒回到登陆界面,不想等待,请点<a href='login.html'>返回登陆</a><font>");
}
%>
</center>
</body>
</html>
这里判断之后不能跳转,但是用response.sendRedirect就是注释掉的那个就可以跳转了,为什么?? 直接用<jsp:forward>根本跳不到success的界面
【 在 nuanyangyang 的大作中提到: 】
: 没错误信息你说个**哔~~~**
就是一个简单登陆界面
这是 login.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="GBK">
<title>登陆实例</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
</head>
<body>
<center>
<h1>登陆界面</h1>
<form action="login.jsp" method="post">
姓名:<input type="text" name="name"><br>
密码:<input type="password" name="pwd"><br>
<input type="submit" name="submit" value="登陆"><br>
<input type="reset" name="reset" value="重置"><br>
</form>
</center>
</body>
</html>
这是login。jsp
<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>Insert title here</title>
</head>
<body>
<center>
<h1>登陆功能实例</h1>
<% request.setCharacterEncoding("GBK");
String name=request.getParameter("name");
String pwd=request.getParameter("pwd");
if(name!=null&&pwd!=null&&name.equals("chenning")&&pwd.equals("123"))
{
// response.sendRedirect("success.jsp");
%>
< jsp:forward page="success.jsp">
<%
}else
{
out.println("<font color='red'> 用户名或密码错误,5秒回到登陆界面,不想等待,请点<a href='login.html'>返回登陆</a><font>");
}
%>
</center>
</body>
</html>
问题就是jsp forward 跳不出去
【 在 mira7 的大作中提到: 】
: 报什么错?