zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    angular设置反向代理
    typescript设置全屏
    解决TS报错Property 'style' does not exist on type 'Element'
    安全错误使用CORS在IE10与Node和Express及XMLHttpRequest: 网络错误 0x4c7, 操作已被用户取消
    vue axios 请求 https 的特殊处理
    SQL Server 查询基础及分组(每三个小时一组)
    SQL Server 表结构操作
    SQL Server 存储过程T-SQL基础语法
    .Net Core 使用Http请求及基于 Polly 的处理故障
    .Net Core 通用主机(Core 在控制台应用程序中的应用)
  • 原文地址:https://www.cnblogs.com/mangwusuozhi/p/10077242.html
Copyright © 2011-2022 走看看