view plaincopy to clipboardprint? <!--遍历二维数组,The trick here is to use 'top' as the value for the inner iterator--> <s:iterator value="aTs" status="of"> <s:if test="#of.last"><br/></s:if> <s:iterator value="top"> <!--亦可用[0].top替代。如果单纯用[0],则会同时打印该处栈对象信息--> <s:property /> </s:iterator> </s:iterator> <!--遍历二维数组,The trick here is to use 'top' as the value for the inner iterator--> <s:iterator value="aTs" status="of"> <s:if test="#of.last"><br/></s:if> <s:iterator value="top"> <!--亦可用[0].top替代。如果单纯用[0],则会同时打印该处栈对象信息--> <s:property /> </s:iterator> </s:iterator>
iterator 标签中的status属性代表当前迭代的位置; #of.last用于判断当前是否跌到的最后一个元素; last返回一个boolean类型; first 返回一个boolean类型; 4)、使用 odd / even 关键字
下面的例子要实现每行输出颜色不同的效果。
defined List<String> days ["Monday","Thursday","Friday","Sunday"]
这里的 <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对象外所有的栈元素。