• <center id="sm46c"></center>
  • <dfn id="sm46c"></dfn>
  • <strike id="sm46c"></strike>
  • <cite id="sm46c"><source id="sm46c"></source></cite>
    • <strike id="sm46c"><source id="sm46c"></source></strike>
      <option id="sm46c"></option>
      国产精品天天看天天狠,女高中生强奷系列在线播放,久久无码免费的a毛片大全,国产日韩综合av在线,亚洲国产中文综合专区在,特殊重囗味sm在线观看无码,中文字幕一区二区三区四区在线,无码任你躁久久久久久老妇蜜桃

      簡(jiǎn)單的驗(yàn)證跳轉(zhuǎn)

      2020-3-6    seo達(dá)人

      一.有關(guān)于內(nèi)置對(duì)象的作用域

      主要說(shuō)明2個(gè)對(duì)象,request,session

      1、request 對(duì)象

      request 對(duì)象是 javax.servlet.httpServletRequest類(lèi)型的對(duì)象。 該對(duì)象代表了客戶(hù)端的請(qǐng)求信息,主要用于接受通過(guò)HTTP協(xié)議傳送到服務(wù)器的數(shù)據(jù)。(包括頭信息、系統(tǒng)信息、請(qǐng)求方式以及請(qǐng)求參數(shù)等)。

      request只在2個(gè)頁(yè)面之間傳遞,每一次新的請(qǐng)求都會(huì)新建一個(gè)request對(duì)象,也就是說(shuō)可能會(huì)request對(duì)象不一致導(dǎo)致空指針異常。

      2、session 對(duì)象

      session 對(duì)象是由服務(wù)器自動(dòng)創(chuàng)建的與用戶(hù)請(qǐng)求相關(guān)的對(duì)象。服務(wù)器為每個(gè)用戶(hù)都生成一個(gè)session對(duì)象,用于保存該用戶(hù)的信息,跟蹤用戶(hù)的操作狀態(tài)。session對(duì)象內(nèi)部使用Map類(lèi)來(lái)保存數(shù)據(jù),因此保存數(shù)據(jù)的格式為 “Key/value”。 session對(duì)象的value可以使復(fù)雜的對(duì)象類(lèi)型,而不僅僅局限于字符串類(lèi)型。

      session對(duì)象在整個(gè)會(huì)話只有一個(gè),也就是說(shuō)session對(duì)象的數(shù)據(jù)會(huì)一直保留直到主動(dòng)進(jìn)行數(shù)據(jù)更改。



      二.表單提交

      在index.jsp中使用form進(jìn)行數(shù)據(jù)的提交,action的目標(biāo)是check.jsp,method是post



      三.驗(yàn)證跳轉(zhuǎn)

      當(dāng)form提交信息后交給check.jsp驗(yàn)證,使用getParameter來(lái)得到form的信息,并使用setAttribute保存。在check.jsp中判斷賬號(hào)密碼是否正確后,使用



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

      1

      進(jìn)行跳轉(zhuǎn),
      .jsp是想要跳轉(zhuǎn)的頁(yè)面路徑。



      四.詳細(xì)代碼

      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">

      請(qǐng)輸入用戶(hù)名:

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

      請(qǐng)輸入密碼:

      <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>驗(yàn)證</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>



      五.注意事項(xiàng)

      在jsp中使用form提交表單不能直接進(jìn)行跳轉(zhuǎn),否則操作不慎就容易出現(xiàn)空指針異常,建議交由單獨(dú)的跳轉(zhuǎn)頁(yè)面處理


      日歷

      鏈接

      個(gè)人資料

      存檔

      主站蜘蛛池模板: 国产精品xxx大片免费观看| 黄频视频大全免费的国产| 色色97| 国产美女直播亚洲一区色| 国产综合色在线精品| 国产麻豆精品一区一区三区| 天天噜噜日日久久综合网| 九九电影网午夜理论片| 无码精品久久久久久人妻中字 | 国产揄拍国产精品| 国产18禁一区二区三区| 无码人妻一区二区三区精品视频| 亚洲色大成成人网站久久| 精品人妻中文字幕在线| 日本丰滿岳乱DVD| 精品久久久久久无码专区不卡| 久久国产自拍一区二区三区| 国产又黄又爽无遮挡不要vip| 无码免费大香伊蕉在人线国产| 久9re热视频这里只有精品| 出租屋勾搭老熟妇啪啪| 国产免费丝袜调教视频免费的| 国内精品人妻无码久久久影院| 久久综合色一综合色88| 香蕉蕉亚亚洲aav综合| 成在线人午夜剧场免费无码| 国内2020揄拍人妻在线视频| 中文字幕丰满乱孑伦无码专区| 亚洲国产精品无码久久98 | av永久天堂一区| 成人精品免费视频| 亚洲综合国产一区二区三区| 国产玖玖玖玖精品电影| 中国熟女仑乱hd| 天堂V亚洲国产V第一次| 人妻精品国产一区二区| 在线无码va中文字幕无码| 儋州市| 一区二区精品久久蜜精品| 中文字幕精品无码一区二区三区 | 国产午夜亚洲精品不卡下载 |