码迷,mamicode.com
首页 > Web开发 > 详细

jsp页面中比较“接收数据”与“页面循环数据”是否相等

时间:2018-12-06 17:51:14      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:jsp页面   数据   test   begin   ring   foreach   必须   方案   解决方案   

页面中关系运算符: 

-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.接收对象

<c:forEach items="${list3}" var="m">
    <li>
      <a href="tileone_selectone.action?id=${m.id}"><img src="${m.picture}"></a>
      <div class="p-price">${m.name}<strong>¥${m.price}</strong></div>
    </li>
</c:forEach>

 

jsp页面中比较“接收数据”与“页面循环数据”是否相等

标签:jsp页面   数据   test   begin   ring   foreach   必须   方案   解决方案   

原文地址:https://www.cnblogs.com/mangwusuozhi/p/10077242.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!