实现简单的网页间的跳转

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>




























































以上是关于实现简单的网页间的跳转的主要内容,如果未能解决你的问题,请参考以下文章

Django框架学习----视图与模板(详情页的上下篇文章跳转跳转)

Android & Flutter 相互跳转

JQuery实现网页的跳转

(八十五)应用程序间的跳转与消息传递

代码设定的按钮与storyboard中的xib页面间的跳转

c#网页之间的跳转语句