`
zhaolei415
  • 浏览: 166670 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

struts2 iterator标签使用说明

阅读更多
最后再来看下在iterator中调用value stack的用法。

假定countries是一个List对象,每一个country有一个name属性和一个citys List对象,并且每一个city也有一个name属性 。那么我们想要在迭代cities是访问countries的name属性就的用如下方式:


view plaincopy to clipboardprint?
<s:iterator value="countries"> 
    <s:iterator value="cities"> 
        <s:property value="name"/>, <s:property value="[1].name"/><br> 
    </s:iterator> 
</s:iterator> 
           <s:iterator value="countries">
               <s:iterator value="cities">
                   <s:property value="name"/>, <s:property value="[1].name"/><br>
               </s:iterator>
           </s:iterator>

这里的 <ww:property value="name"/>取的是ctiy.name;<ww:property value="[1].name"/>取得是country.name
<ww:property value="[1].name"/> 等价于 <ww:property value="[1].top.name"/>
we refer to a specific position on the stack: '[1]'. The top of the stack, position 0, contains the current city, pushed on by the inner iterator; position 1 contains the current country, pushed there by the outer iterator.(city处于当前栈,即top或者[0],而[1]指明了外层iterator对象,即country)
'[n]'标记引用开始位置为n的子栈(sub-stack),而不仅仅是位置n处的对象。因此'[0]'代表整个栈,而'[1]'是除top对象外所有的栈元素。


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jackyrongvip/archive/2009/11/24/4867325.aspx
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics