EL表达式使用判断

双引号里面是字符串直接是错误

<c:iftest="1==1"></c:if>     false

<c:iftest="${‘1==1’ }"></c:if>  false

 

后台取出来currenPage1比较

<c:iftest="${currenPage==1 }"></c:if>  true

<c:iftest="${1==1 }"></c:if>     true

 

 

 

后台取出的值和字符串INDEX_PAGE比较



el判断是否为空

方式一

判断restaurantInfo 和restaurantInfo.resultList不为null

 <c:if test="${restaurantInfo != null && restaurantInfo.resultList != null }">


方式二

判断restaurant和restaurant.avgPrice不为null

<c:if test="${!empty restaurant && !empty restaurant.avgPrice}"></c:if>
        


<c:choose> 、<c:when>和<c:otherwise>使用演示

 <%
     request.setAttribute("num",1);
   
   %>

    <c:choose>
         <c:when test="${num ==1 }"> num =1 </c:when>
         <c:when test="${num ==2 }"> num =2</c:when>    
         <c:otherwise> num !=1 &&num !=2</c:otherwise>
    </c:choose>

注意:

<c:when>必须在<c:otherwise>之前

<c:choose>之间只能有<c:when>和<c:otherwise>,不能有其他元素

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值