jstl--->Core 核心标签库->流程控制

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>

 

原文地址:https://www.cnblogs.com/juniorjava/p/7263923.html