jsp:forward动作功能

jsp:forward动作:引导请求者进入新的页面

例子:login.jsp

<center>
<p>
用户登录

</p>
<form name="form1" method="post" action="loginReceive.jsp">
<label>姓名<input type="text" name="userName" size="10px"></label>
<br>
<label>密码<input type="password" name="userPwd" size="10px"></label>
<br>
<label> 
<input type="submit" name="Submit" value="登录">
</label>
<label><input type="reset" name="Submit2" value="重置">
</label>
</form>
</center>
View Code

loginReceive.jsp内容

<%
String Name=request.getParameter("userName");
String password=request.getParameter("userPwd");
if(Name.equals("hgw")&& password.equals("123"))
{
%>
<jsp:forward page="loginCorrect.html"></jsp:forward>
<%
}
else
%>
<jsp:forward page="loginError.html"></jsp:forward>
View Code

 

loginCorrect.html内容

您已成功登录!!!

loginError.html

用户名错误,<a href="login.jsp">请重试</a>

 

posted @ 2017-10-22 19:25  江上玉坠  阅读(276)  评论(0编辑  收藏  举报