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>
