中 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>
                                  </c:if> 

1111111
                                 </tr> 
                        </c:forEach>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章