zoukankan      html  css  js  c++  java
  • <c:forEach varStatus="status">中 varStatus的作用

    varStatus是<c:forEach>jstl循环标签的一个属性,varStatus属性。

    varStatus=“status”事实上定义了一个status名的对象作为varStatus的绑定值。

    该绑定值也就是status封装了当前遍历的状态,比如,可以从该对象上查看是遍历到了第几个元素:${status.count}

    <span style="color: red; font-size: 20px;">${status.count}</span> 写在 c:forEach 里面.

    常见的用法的是<c:forEach var="e" items="${ss.list}" varStatus="status">
                                     <!--实现隔行变色效果--> 
                                     <c:if test="${status.count%2==0}" >
                                           <tr  style="color: red; font-size: 20px;"/>
                                      </c:if>

                                      <c:if test="${status.count%2!=0}" >
                                           <tr  style="color: blue; font-size: 20px;"/>
                                      </c:if> 

                            </c:forEach>

         <c:forEach items="${students}" var="s" varStatus="vs">    
             <tr style='background-color: ${vs.count %2==0 ?"blue":"gray"};'>
                 <td>${s.id }</td>
                 <td>${s.name }</td>
                 <td>${s.age }</td>
             </tr>
        </c:forEach>

    分行显示蓝色或则灰色。

  • 相关阅读:
    【[SDOI2016]排列计数】
    newcoder NOIP提高组模拟赛C题——保护
    【[JLOI2014]松鼠的新家】
    【[USACO08NOV]奶牛混合起来Mixed Up Cows】
    【[USACO13NOV]没有找零No Change】
    【[SHOI2009]会场预约】
    【[USACO12FEB]附近的牛Nearby Cows】
    UVA11987 【Almost Union-Find】
    基于递归的BFS(Level-order)
    遍历二叉树
  • 原文地址:https://www.cnblogs.com/jianshuai520/p/9473041.html
Copyright © 2011-2022 走看看