国产精品美女久久久浪潮AV,国产精品三级一二三区,久久精品国产一区二区小说 ,依依成人影视国产精品,全部无卡免费的毛片在线看,日本一区二区三深夜不卡,国产精品女同一区二区久久,国产精品夜色一区二区三区

        簡單的驗證跳轉

        2020-3-6    seo達人

        一.有關于內置對象的作用域

        主要說明2個對象,request,session

        1、request 對象

        request 對象是 javax.servlet.httpServletRequest類型的對象。 該對象代表了客戶端的請求信息,主要用于接受通過HTTP協議傳送到服務器的數據。(包括頭信息、系統信息、請求方式以及請求參數等)。

        request只在2個頁面之間傳遞,每一次新的請求都會新建一個request對象,也就是說可能會request對象不一致導致空指針異常。

        2、session 對象

        session 對象是由服務器自動創建的與用戶請求相關的對象。服務器為每個用戶都生成一個session對象,用于保存該用戶的信息,跟蹤用戶的操作狀態。session對象內部使用Map類來保存數據,因此保存數據的格式為 “Key/value”。 session對象的value可以使復雜的對象類型,而不僅僅局限于字符串類型。

        session對象在整個會話只有一個,也就是說session對象的數據會一直保留直到主動進行數據更改。



        二.表單提交

        在index.jsp中使用form進行數據的提交,action的目標是check.jsp,method是post



        三.驗證跳轉

        當form提交信息后交給check.jsp驗證,使用getParameter來得到form的信息,并使用setAttribute保存。在check.jsp中判斷賬號密碼是否正確后,使用



        <jsp:forward page=".jsp"></jsp:forward>

        1

        進行跳轉,
        .jsp是想要跳轉的頁面路徑。



        四.詳細代碼

        index.jsp



        <%@ page language="java" import="java.util." pageEncoding="UTF-8"%>

        <%

        String path = request.getContextPath();

        String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

        %>



        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

        <html>

          <head>

            <base href="<%=basePath%>">

            

            <title>登陸</title>

            

        <meta http-equiv="pragma" content="no-cache">

        <meta http-equiv="cache-control" content="no-cache">

        <meta http-equiv="expires" content="0">    

        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

        <meta http-equiv="description" content="This is my page">

        <!--

        <link rel="stylesheet" type="text/css" href="styles.css">

        -->



          </head>

          

          <body>



           <form action="check.jsp" method="post">

        請輸入用戶名:

        <input type = "text" name = "username"><br/>

        請輸入密碼:

        <input type = "password" name = "passwd"><br/>

        <input type="submit" name="submit" value="登錄">

        </form>

         

          </body>

        </html>





        check.jsp



        <%@ page language="java" import="java.util.
        " pageEncoding="UTF-8"%>

        <%

        String path = request.getContextPath();

        String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

        %>



        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

        <html>

          <head>

            <base href="<%=basePath%>">

            

            <title>驗證</title>

            

        <meta http-equiv="pragma" content="no-cache">

        <meta http-equiv="cache-control" content="no-cache">

        <meta http-equiv="expires" content="0">    

        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

        <meta http-equiv="description" content="This is my page">

        <!--

        <link rel="stylesheet" type="text/css" href="styles.css">

        -->



          </head>

          

          <body>

           

        <%

          String username = (String)request.getParameter("username");

          String passwd = (String)request.getParameter("passwd");

          request.setAttribute("username", username);

          request.setAttribute("passwd", passwd);

         

          if(username.equals("admin")&&passwd.equals("123")){

        %>

        <jsp:forward page="succeed.jsp"></jsp:forward> 

        <%}else{ %>

        <jsp:forward page="failed.jsp"></jsp:forward> 

        <%} %>

          </body>

        </html>



        succeed.jsp



        <%@ page language="java" import="java.util." pageEncoding="UTF-8"%>

        <%

        String path = request.getContextPath();

        String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

        %>



        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

        <html>

          <head>

            <base href="<%=basePath%>">

            

            <title>登陸成功</title>

            

        <meta http-equiv="pragma" content="no-cache">

        <meta http-equiv="cache-control" content="no-cache">

        <meta http-equiv="expires" content="0">    

        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

        <meta http-equiv="description" content="This is my page">

        <!--

        <link rel="stylesheet" type="text/css" href="styles.css">

        -->



          </head>

          

        <body>

        <% 

        String username = (String)request.getAttribute("username");

        String passwd = (String)request.getAttribute("passwd");



        %>

        <%=username %>登陸成功



        </body>

        </html>



        failed.jsp



        <%@ page language="java" import="java.util.
        " pageEncoding="UTF-8"%>

        <%

        String path = request.getContextPath();

        String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

        %>



        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

        <html>

          <head>

            <base href="<%=basePath%>">

            

            <title>登陸失敗</title>

            

        <meta http-equiv="pragma" content="no-cache">

        <meta http-equiv="cache-control" content="no-cache">

        <meta http-equiv="expires" content="0">    

        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

        <meta http-equiv="description" content="This is my page">

        <!--

        <link rel="stylesheet" type="text/css" href="styles.css">

        -->



          </head>

        <body>

        <% 

        String username = (String)request.getAttribute("username");

        String passwd = (String)request.getAttribute("passwd");



        %>

        <%=username %>登陸失敗

        </body>

        </html>



        五.注意事項

        在jsp中使用form提交表單不能直接進行跳轉,否則操作不慎就容易出現空指針異常,建議交由單獨的跳轉頁面處理


        日歷

        鏈接

        個人資料

        藍藍設計的小編 http://www.shtzxx.cn

        存檔

        主站蜘蛛池模板: 1000部精品久久久久久久久| 欧美超级乱婬视频播放| 妺妺跟我一起洗澡没忍住| 午夜一区欧美二区高清三区| 亚洲欧美日韩一区二区| 爱啪啪av导航| 得荣县| 人人曰人人做人人| 五月婷婷综合缴情六月| 亚洲欧美中文字幕在线一区二区 | 色翁荡息又大又硬又粗又视频图片| free性丰满熟女hd| 黑人巨大两根一起挤进交换 | 男女一边摸一边做爽爽电视| 成全免费高清电影| 狠狠干狠狠爱| 岳阳县| 四虎国产精品永久地址入口 | 中文乱码人妻系列一区| xxxxx做受大片在线观看免费| 免费120秒体验试看5次| 最近日本免费高清完整版| 芒果乱码一线二线三线新区| 300部国产真实乱| 精品日韩卡1二2卡3卡4卡乱码| 武平县| 午夜无码片在线观看影院| 亚洲 卡通 欧美 制服 中文| 精品无码国产自产野外拍在线| 青青草97国产精品免费观看| 国产精品人妻一码二码| 空之色| 人妻阿敏被老外玩弄系列| 镇远县| 欧美怡红院成免费人忱友;| 色综合99久久久无码国产精品 | wc女厕撒尿七ⅴ偷拍| 亚洲av永久无码精品秋霞电影影院| 日本成本人片视频免费| 少妇人妻无码精品视频| 国产精品186在线观看在线播放|