jstl--->Core 核心標籤庫->流程式控制制

來源:互聯網
上載者:User

標籤:運算   false   範圍   test   沒有   stc   條件判斷   ...   標籤庫   

jstl--->Core 核心標籤庫->流程式控制制  

  -->if、choose、when、otherwise

   <c:if>條件判斷  

    文法1:沒有本體內容

     <c:if test="testCondition" var="varName" [scope="{page|request|session|application}"]/>  

    文法2:有本體內容  

    <c:if test="testCondition" [var="varName"] [scope="{page|request|session|application}"]>  本體內容...  </c:if>    

  屬性

    test:如果運算式的結果為true則執行本體內容,false則相反  

    var:儲存test運算後的結果,true或false  

    scope:var變數的jsp範圍    

  栗子:  

  <c:if test="${param.username == ‘Admin‘}" var="condition" scope="page">

    您好!Admin先生。  

  </c:if>

  </br>  執行結果為:${condition}   

   運算完成會將test的結果賦值給condition存入page中

   <c:choose>本身只當做<c:when>和<c:otherwise>的父標籤  

  若要使用<c:when>和<c:otherwise>來做流程式控制制時,他們必須為<c:choose>的子標籤    

  <c:when>  

  文法  <c:when test="testCondition" >  本體內容...        

    </c:when>

     test:如果運算式結果為true,則執行本體內容,false則相反  

  <c:otherwise>  

  所有<c:otherwhen>的test都不為true就執行  

    <c:otherwise>  

    本體內容...  

    </c:otherwise>

 

jstl--->Core 核心標籤庫->流程式控制制

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.