实现简单的网页间的跳转
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实现简单的网页间的跳转相关的知识,希望对你有一定的参考价值。
代码:
login.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<br/>
<center>
<form action="check.jsp" method="post">
<input type="text" name="userName"><br>
<input type="password" name="password"><br>
<input type="submit" value="提交">
<input type="reset" value="重置">
</form>
</center>
</body>
</html>
check.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<body>
<%
request.setCharacterEncoding("utf-8");
String str1 = request.getParameter("userName");
String str2 = request.getParameter("password");
if( str1.equals("aaa") && str2.equals("aaa") ){
%>
<jsp:forward page="success.jsp"></jsp:forward>
<%
}else{
%>
<jsp:forward page="fail.jsp"></jsp:forward>
<%} %>
</body>
</html>
success.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<center>
<% String str1 = request.getParameter("userName"); %>
<% String str2 = request.getParameter("password"); %>
<h3><%=str1 %>!!! </h3>
<h3><%=str2 %></h3>
<h1>you are welcome!</h1>
</center>
</body>
</html>
fail.jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<center>
<h1>登陆失败</h1><br>
<h1> <a href="login.jsp">请重新登陆</a> </h1>
</center>
</body>
</html>
以上是关于实现简单的网页间的跳转的主要内容,如果未能解决你的问题,请参考以下文章