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>

    分行显示蓝色或则灰色。

  • 相关阅读:
    ORACLE DROP TABLE和truncate table的区别
    C#版链表加强版
    C#版栈
    再谈为什么要使用MONO
    流浪猫伏击大白鹅
    编写ASP.NET复合控件实例
    C# 大文件拷贝
    关于团队项目构架设计的疑问
    在Windows平台下使用MONO
    C#版链表
  • 原文地址:https://www.cnblogs.com/jianshuai520/p/9473041.html
Copyright © 2011-2022 走看看