页面中关系运算符: 

-lt    小于 
-le     小于或者等于 
-gt    大于 
-ge    大于或者等于 
-eq    等于 
-ne    不等于 

判空:<c:if test="${empty count }"></c:if>  

例子:

//count=1   
<c:if test="${count eq 1}">(equals)等于1</c:if>   
//count!=1   
<c:if test="${count ne 1}">(equals)不等于1</c:if>   
//count>=2   
<c:if test="${count ge 2}">(gt eq)大于等于2<c:if>   
//count<2   
<c:if test="${count le 2}">(lt eq小于等于2<c:if>   
//count>1   
<c:if test="${count gt 1}">(gt)大于1<c:if>   
//count<1   
<c:if test="${count lt 1}">(lt)大于1<c:if>  

关于“没有”的解决方案:

<c:if>没有<c:else>可以用<c:choose>来取代结构:
<c:choose>
   <c:when test="">    如果
   </c:when>
   <c:otherwise>  否则
   </c:otherwise>
</c:choose>
 
在同一个 <c:choose> 中,当所有 <c:when> 的条件都没有成立时,则执行 <c:otherwise> 的本体内容。
 
  语法
 
  <c:otherwise>
  本体内容
  </c:otherwise>
  属性
  无

  限制
  ·<c:otherwise> 必须在 <c:choose></c:choose>之间
  ·在同一个 <c:choose> 中时,<c:otherwise> 必须为最后一个标签
 
  说明
  在同一个 <c:choose> 中,假若所有 <c:when> 的test属性都不为true时,则执行 <c:otherwise> 的本体内容。
 

实例:

1.两个如果,选择显示true和false结果

<c:forEach var="i" begin="1" end="${num3}">//页面循环
    <c:if test="${ye3 eq i}">//如果成功
        <a href="total_sel.action?ye3=${i}" style="color: #000">[${i}]</a>
    </c:if>
    <c:if test="${ye3 ne i}">//如果失败(因为没有else)
        <a href="total_sel.action?ye3=${i}" style="color: red">[${i}]</a>
    </c:if>
</c:forEach>  
2)
<
c:choose> <c:when test="${ye2 eq i}"> 如果true,输出结果 </c:when> <c:otherwise> 否则,输出结果 </c:otherwise> </c:choose>

 

2.接收对象

status.index下标
status.count数量
<
c:forEach items="${list3}" var="m" varStatus="status"> <li>
    <c:if test="${status.index < 4 }">
  <a href="tileone_selectone.action?id=${m.id}"><img src="${m.picture}"></a>   <div class="p-price">${m.name}<strong>¥${m.price}</strong></div>
    
</c:if>
</li>
</c:forEach>

 

posted on 2018-12-06 16:06  茫无所知  阅读(228)  评论(0编辑  收藏  举报