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


    页面中关系运算符: 

    -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>
  • 相关阅读:
    设计模式 享元模式(池化技术)
    设计模式 混合模式(整体部分模式)
    设计模式 适配器模式
    Flex3示例、 安装 、注册码
    VS2010错误
    转载:glut.h 与 stdlib.h中 的exit()重定义问题的解决
    宿迁软件QQ群(109233721)
    百度地图 开发API接口啦
    Sublime Text 插件个人使用总结&推荐
    sublime text2 使用安装插件中文乱码问题解决
  • 原文地址:https://www.cnblogs.com/mangwusuozhi/p/10077242.html
Copyright © 2020-2023  润新知