jsp:forward动作:引导请求者进入新的页面
例子:login.jsp
<center>
<p>
用户登录
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
</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>
loginReceive.jsp内容
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
<% 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>
loginCorrect.html内容
您已成功登录!!!
loginError.html
用户名错误,<a href="login.jsp">请重试</a>