zoukankan      html  css  js  c++  java
  • 在c:forEach与s:iterator里面使用if标签判断当前位置是否为2的倍数

    c:forEachs:iterator里面使用if标签判断当前位置是否为2的倍数

    c:forEach:

    <c:forEach var="workflow" items="${workflowList}">
        <tr
        <c:if test="${workflowList.indexOf(workflow) % 2 == 0}"> class="lightTr"</c:if>>
            <td><input type="checkbox" name="isWorkflow"
                value="${workflow.workflowId}" />
            </td>
            <td><a
                href="javascript:workflowAddorEdit('edit','${workflow.workflowId}')">${workflow.workflowName}</a>
            </td>
        </tr>
    </c:forEach>
    
    1. 如果是set集合的时候呢?indexOf还能用吗?
    2. indexOf的下标从0开始,为了给第一行数据加入class,所以用了%2 == 0

    s:iterator:

    <ul>
        <li class="firstLi">
        <input type="checkbox" id="ctlUserIds" onclick="wcmAppCommon.checkBox.selectAll(this,'catalogUserIds');"/>&nbsp;&nbsp;栏目名称</li>
        <s:if test="catalogUserList.isEmpty()">
        <li>暂无相关数据</li>
        </s:if>
    <s:iterator value="catalogUserList" id="catalogUser" status="i">
        <li<s:if test="#i.count%2 != 0"> class="lightTr"</s:if>><input type="checkbox" name="catalogUserIds" value="<s:property value="#catalogUser.catalogUserId"/>"/>&nbsp;&nbsp;<s:property value="#catalogUser.catalog.catalogFullName"/>
        </li>
    </s:iterator>
    </ul>
    
    1. s:iterator显然封装的更好。
    2. i.count 是从1开始的。

    3. 用s:if判断list是否为空

      <s:if test="catalogManageList.isEmpty()">`
          <li>暂无相关数据</li>
      </s:if>
      

      s:iterator之前使用,因为s:iterator本身会判断是不是空才进去干活。

  • 相关阅读:
    MegaCli 简易使用介绍
    【转】RAID 技术发展综述
    HOWTO For iSCSI-SCST && Gentoo HOWTO For iSCSI-SCST
    FC磁盘设备管理
    targetcli配置iSCSI
    NVMe协议1.3c(一) 概述
    NVMe概述
    Jenkins slave image
    ansible module
    Ansible Filter
  • 原文地址:https://www.cnblogs.com/nimeiz/p/3444457.html
Copyright © 2011-2022 走看看