EL表达式使用判断

来源:互联网 发布:又拍云存储 域名 编辑:程序博客网 时间:2024/05/27 00:46

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

<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>,不能有其他元素