iterator索引

iterator有多个属性,其中要显示该元素在集合中的位置可以使用status属性,包含了以下属性方法:

 

Count:迭代元素个数 

Index: 迭代元素当前索引

Even: 是否为偶

Odd: 是否为奇

First: 是否为第一个 

Last: 是否最后一个

 

其索引属性index是从0开始的

若想从1开始可以使用count,count=index+1

<s:iterator value="questions" id="q" status='st'>
<s:property value='#st.count'/> <br/>
标题:<s:property value='#q.QTitle'/> <br/>
积分:<s:property value='#q.QIntegral'/><br/>
内容:<s:property value='#q.QContent'/><br/>
</s:iterator>

猜你喜欢

转载自imjiang.iteye.com/blog/1028509