JAVA 筆記no.2

來源:互聯網
上載者:User

標籤:lib   找不到   https   other   sts   include   bsp   library   font   

1.JSP中的各種元素:程式碼片段、注釋、內建對象、運算式

  (1)程式碼片段:<%    %>

  (2)注釋:<%--     %>(HTML)、<%//    %>或<%/*    /*%>(Java)

  (3)內建對象:request、response、session、application、config、exception、out、page、pageContext

  (4)JSP運算式:<%=    %>

  (5)JSP定義塊:

   ①全域變數(定義方法也用):<%!   %>

   ②局部變數:<%=    %>

  (6)JSP指令:<%指令名 屬性1=值1,……,屬性n=值n    %>

   ①page指令:定義整個頁面的全域屬性

     <%@page …… %>

   ②include指令:用於包含一個文本or代碼的檔案

     <%@include …… %>

  (7)其他

   ①引入標籤庫:<%@ taglib uri=”   ” prefix=”   ” %>

   ②不建立session:<%@page …… session=”false” %>

 

2.EL(Expression Language)運算式、EL對某種範圍的機制

  (1)運算式

   ①算數運算:1+2=${1+2}

   ②關係運算:5>3?${5>3}

   ③邏輯運算:5>3 and 3<2?${5>3 and 3<2}

               5>3 or 3<2?${5>3 or 3<2}

               not 5>3?${not (5>3)}

  (2)範圍機制

   獲得某範圍資料:username:${requestScope.username},username:${sessionScope.username},username:${applicationScope.username}

   如,username:${username},若沒指定範圍,則從最小範圍開始找,即從requestScope中找。找不到,則找大範圍(順序:page→request→session→application);都沒找到,則顯示空白。

 

3.JSP標籤(JSP動作)

  (1)<jsp:forword page=”main.jsp”></jsp:forword>

  (2)<jsp:include page=”main.jsp”></jsp:include>

 

4.熟悉TLD(Tag Library Description file,標籤庫描述)檔案內容

  *.TLD 說明了標籤庫中標籤的使用方式。TLD檔案位於JSTL 1.2.2 Library/jstl-impl-1.2.2.jar/META-INF/maven中。

  如C標籤庫:

  JSTL 1.2.2 Library/jstl-impl-1.2.2.jar/META-INF/maven中的c.tld檔案。

  其中的<uri>http://java.sun.com/jsp/jstl/core</uri>表示它的地址。

  <short-name>c</short-name>表示建議使用的簡稱。

  <tag></tag>表示C標籤中的屬性。

 

5.瞭解C標籤庫

  JSTL 1.2.2 Library/jstl-impl-1.2.2.jar/META-INF/maven中的c.tld檔案。

  其中的<uri>http://java.sun.com/jsp/jstl/core</uri>表示它的地址。

  <c:if test=”……”></c:if>、<c:when test=”……”></c:when>、<c:out value=”……”></c:out>、<c:url value=”……”></c:if>、<c:choose></c:choose>、<c:otherwise></c:otherwise>

 

6.三層架構分為哪三層

  表現層(presentation layer)、商業邏輯層(business layer)、資料持久化(persistence layer)

 

7.重新導向代碼

  (1)response.sendRedirect(“load_student.jsp”);

  (2)<jsp:forword page=”load_student.jsp”></jsp:forword>

  區別:

  (1)只能用<jsp:forword>在本網站內跳轉,而response.sendRedirect能跳轉到任何一個地址的頁面。

  (2)<jsp:forword>帶著request中的資訊跳轉,而sendRedirect不帶request資訊跳轉。

 

8.瞭解servlet生命週期

  servlet生命週期定義了一個servlet如何被載入、初始化,以及它怎樣接收請求、響應請求,提供服務。

  (1)init()

  在Servlet的生命週期中,僅執行一次init()方法,它是在伺服器裝入Servlet時執行的,可以設定管理員。

  (2)service()

  每當一個客戶請求一個HttpServlet對象,該對象的Service()方法就要調用。

  (3)destroy()

  僅執行一次,在伺服器端停止且卸載Servlet時執行該方法。

JAVA 筆記no.2

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.