实现简单的网页间的跳转
?
?
?
?
代碼:
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>
轉載于:https://www.cnblogs.com/qq1206050421/p/7615762.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的实现简单的网页间的跳转的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iOS 高效的分页加载
- 下一篇: projecteuler_problem