<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                *** [jstl下載](https://pan.baidu.com/s/1ka9vyxk_o0NVpYUMrBwkmA) *** JavaServer Pages Standard Tag Library (1.1 ) ,它的中文名稱為 JSP 標準標簽函數庫。JSTL 是一個標準的已制定好的標簽庫,可以應用于各種領域,如:基本輸入輸出、流程控制、循環、XML 文件剖析、數據庫查詢及國際化和文字格式標準化的應用等。從表 7-1 可以知道,JSTL 所提供的標 簽函數庫主要分為五大類: (1)核心標簽庫 (Core tag library) (2)I18N 格式標簽庫 (I18N-capable formatting tag library) (3)SQL 標簽庫 (SQL tag library) (4)XML 標簽庫 (XML tag library) (5)函數標簽庫 (Functions tag library) 表 。 ![](https://box.kancloud.cn/0b256f9edab5416b5c4bdc128737539b_930x195.png) ## 安裝 直接把JSTL有關的兩個jar包,拷貝進lib目錄下 然后在jsp頁面上添加指令,就可以使用了 ~~~ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> ~~~ ## 功能 ![](https://box.kancloud.cn/d2e0d30e6923dda8247acf2f3e2c0913_931x538.png) #### 表達式操作 <c:out> ![](https://box.kancloud.cn/485c77e885ef245a476fee8ba7039df5_571x166.png) value屬性相對重要,其他兩個作為了解 ~~~ <h4>c:out</h4> <% request.setAttribute("book", "<<Java>>"); %> // 把<>當成; 標簽,無法正常進行解析 book:${ requestScope.book } <br> book:<c:out value="${ requestScope.book }" default="NoBook"></c:out> ~~~ <c:set> <c:set>主要用來將變量儲存至 JSP 范圍中或是 JavaBean 的屬性中。 ![](https://box.kancloud.cn/0fec146330e5b47252cf058e2e89890e_865x249.png) ~~~ <c:set var="name" value="neusoft" scope="page"></c:set> // 兩者等效 <% pageContext.setAttribute("name", "neusoft"); %> name:${ pageScope.name } ~~~ ~~~ <% Customer customer = new Customer(); customer.setId(1001); request.setAttribute("cus", customer); %> ID:${ requestScope.cus.id } <c:set target="${ requestScope.cus }" property="id" value="1002"></c:set> ID:${ requestScope.cus.id } ~~~ <c:remove> <c:remove>主要用來移除變量。 ~~~ <c:set value="1999-09-09" var="date" scope="session"></c:set> date: ${ sessionScope.date } <c:remove var="date" scope="session"/> date: ${ sessionScope.date } ~~~ *** #### 流程控制 <c:if> <c:if>的用途就和我們一般在程序中用的 if 一樣 ![](https://box.kancloud.cn/52c7b935eb30e3fdf7dfb5a54012bfe2_698x179.png) ~~~ <c:set value="33" var="age" scope="session"></c:set> <!-- 沒有else,但能儲存結果 --> <c:if test="${ sessionScope.age > 18 }">成年人</c:if> <c:if test="${ sessionScope.age > 18 }" var="isAdult" scope="session"></c:if> isAdult:<c:out value="${ sessionScope.isAdult }"></c:out> ~~~ <c:choose> <c:choose>本身只當做 <c:when> 和 <c:otherwise> 的父標簽。 <c:when> 和 <c:otherwise>也不能脫離<c:choose>。 <c:otherwise>必須在<c:when>之后使用。 ~~~ <c:choose> <c:when test="${param.age > 60 }"> 老年 </c:when> <c:when test="${param.age > 40 }"> 中年 </c:when> <c:when test="${param.age > 18 }"> 青年 </c:when> <c:otherwise> 未成年 </c:otherwise> </c:choose> ~~~ *** #### 迭代操作 **<c:forEach>** <c:forEach> 為循環控制,它可以將集合(Collection)中的成員循序瀏覽一遍。運作方式為當條件符合時,就會持續重復執行<c:forEach>的本體內容。 ![](https://box.kancloud.cn/3b21ede43f9586fe39e6fa0215e58908_929x477.png) ~~~ <c:forEach begin="1" end="10" step="3" var="i"> ${ i } -- </c:forEach> ~~~ 遍歷Collection(數組也一樣) ~~~ <% List<Customer> list = new ArrayList<Customer>(); list.add(new Customer(1001,"leo1","sheyang1","19012345678")); list.add(new Customer(1002,"leo2","sheyang2","19012345678")); list.add(new Customer(1003,"leo3","sheyang3","19012345678")); list.add(new Customer(1004,"leo4","sheyang4","19012345678")); list.add(new Customer(1005,"leo5","sheyang5","19012345678")); request.setAttribute("list", list); %> <c:forEach items="${ requestScope.list }" var="customer"> ${ customer.id } --${ customer.name } --${ customer.address } --${ customer.phone }<br><br> </c:forEach> ~~~ ~~~ // begin從0開始,step為步長,end為到哪結束,這樣只能遍歷出3條記錄 <c:forEach items="${ requestScope.list }" var="customer" begin="0" step="2" end="4"> ${ customer.id } --${ customer.name } --${ customer.address } --${ customer.phone }<br><br> </c:forEach> ~~~ 遍歷Map集合 ~~~ <% Map<String,Customer> map = new HashMap<String,Customer>(); map.put("A",new Customer(1001,"leo1","sheyang1","19012345678")); map.put("B",new Customer(1002,"leo2","sheyang2","19012345678")); map.put("C",new Customer(1003,"leo3","sheyang3","19012345678")); map.put("D",new Customer(1004,"leo4","sheyang4","19012345678")); map.put("E",new Customer(1005,"leo5","sheyang5","19012345678")); request.setAttribute("map", map); %> <c:forEach items="${ requestScope.map }" var="customer"> ${ customer.key } --- ${ customer.value.id },${ customer.value.name },${ customer.value.address },${ customer.value.phone }<br><br> </c:forEach> ~~~ 遍歷數組 ~~~ <% String str[] = {"aaa","bbb","ccc"}; // 一定要在某一個域對象當中,否則拿不到 request.setAttribute("names", str); %> <c:forEach items="${ requestScope.names }" var="name">${ name }--</c:forEach> ~~~ <c:forTokens> 類似于String類的split方法 ~~~ <% String str = "a,b,c,d,e"; request.setAttribute("str", str); %> <c:forTokens items="${ str }" delims="," var="str">${ str }<br></c:forTokens> ~~~ *** #### URL操作 <c:import> <c:import> 可以把其他靜態或動態文件包含至本身 JSP 網頁。 ~~~ <c:import url="http://www.baidu.com"></c:import> ~~~ <c:redirect> <c:redirect>使當前JSP頁面重定向到指定的頁面(因為是交于服務器解析,所以這里的/代表的是WEB應用根目錄) ~~~ <c:redirect url="/link.jsp"></c:redirect> ~~~ <c:url> <c:url>可以產生一個url地址,可以根據Cookie是否可用,智能進行URL重寫,對Get請求參數進行編碼 ~~~ <h1>JSTL Page</h1> <c:url value="/link.jsp" var="testurl" scope="page"> <c:param name="name" value="東軟睿道"></c:param> </c:url> url:${ testurl } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看