Struts1.3 Tag总结之----Logic:iterate

<logic:iterate />

Iterates over a collection, enumerator, iterator, map, or array. It evaluates its body for each item in the collection.

 

collection是对象的一个属性(request scope中存在的对象 tagInfo 属性 objHobbies是一个 collection)

 

<logic:iterate id="iter" name="tagInfo" property="objHobbies" scope="request">

       <bean:write name="iter" property="id"/>

       <bean:write name="iter" property="name"/>

    </logic:iterate>

 

 

collection就是存在于request scope中的对象,由于用了collection属性,不能用name属性去绑定对象,所以必须用表达式的形式得到对象。Offset表示从集合中索引(index)为多少的元素开始取,length表示取几个元素。indexId存放着元素的索引值。

 

<logic:iterate id="iter" collection="${options}" offset="1" length="5" indexId="index">

       <bean:write name="iter" property="id"/>

       <bean:write name="iter" property="value"/>

       [<bean:write name="index"/>]

    </logic:iterate>

 

 

    遍历HashMapMap中的每一对 key-value pair被保存在名为 iter 的对象中。

    <logic:iterate id="iter" name="tagInfo" property="multipleParam">

       <bean:write name="iter" property="key" />

       <bean:write name="iter" property="value" />

    .</logic:iterate>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值