zoukankan      html  css  js  c++  java
  • el表达式 if 和 if else 的写法

    javaScript的if else大家都不会陌生,但可能很多小伙伴并不知道在jsp文件里,el表达式的if else是怎么写的,下面安利给各位小伙伴。

    el表达式 if 代码示例
    示例1
    <c:if test="${jsonObject.transportTypeName eq '火车'}">
         <li><span>运费</span><span class="orderdetails-jiage-1">0</span></li>
    </c:if>
    

    示例2

    <c:if test="${empty currentRoleId}"> 
         currentRoleId为空 
    </c:if> 
    <c:if test="${not empty currentRoleId}"> 
         currentRoleId不为空 
    </c:if> 
    

      

    示例3

    <c:when test="${condition1}">  
      
      condition1为true  
      
    </c:when> 
    

      

     
    el表达式 if  else代码示例  使用choose  when otherwise 
    示例1
    <c:choose>
         <c:when test="${jsonObject.transportTypeName eq '火车' || '散船' || '自提' || '集装箱' || '集装箱自提' || '汽车'}">
              <li><span>运费</span><span class="orderdetails-jiage-1">0</span></li>
         </c:when>
         <c:otherwise>
              <li><span>运费</span><span class="orderdetails-jiage-1">¥${jsonObject.deliveryFee == null ? 0.00 : jsonObject.deliveryFee}</span></li>
         </c:otherwise>
    </c:choose>
    

      

    示例2

    <c:choose>
    <c:when test="${var.index % 2 == 0}">
           *
    </c:when>
    <c:otherwise>
           *
    </c:otherwise>
    </c:choose>
    

      

    示例3

    <c:choose>
         <c:when test="${Object.Name != null}">
                    *
         </c:when>
         <c:otherwise>
                   *
         </c:otherwise>
    </c:choose>
    

      

  • 相关阅读:
    Vue请求参数转换(qs的使用---对象序列化)
    Vue中使用async/await解决异步请求问题
    数据结构:set
    数据结构:map (不是数组的map方法)
    数组方法-reduce 和 ES6扩展运算符
    数据分析相关
    Hadoop委任和解除节点
    Oozie调度Sqoop报错
    Oozie调度Sqoop的两种方式
    MySql数据表直接到Hive表操作
  • 原文地址:https://www.cnblogs.com/master-yao/p/8195585.html
Copyright © 2011-2022 走看看