Said another way, let's say I have a value stack that consists of a
model and an action as follows:

[ model, action ]
here's how the following ognl would resolve:
[0] - a CompoundRoot object that contains our stack, [model, action]

[1] - another CompoundRoot that contains only [action]

[0].toString() - calls toString() on the first object in the value stack (excluding the CompoundRoot) that supports the toString() method

[1].foo - call getFoo() on the first object in the value stack starting from [OS:action] and excluding the CompoundRoot that supports a getFoo() method

以上是webwork文档中谈到Value Stack部分.看了有些晦涩,我试验了下,与大家分享.(没看源代码)
Action:

public class HomeAction implements Action {
    
private String name= "propertyOfAction";
    
private Person person=null;
    
private Collection collection = new ArrayList();
    
public String execute() throws Exception {
        collection.add(
new Person("zkj"));
        collection.add(
new Person("yql"));
        collection.add(person);
        
return SUCCESS;
    }

    
public String getName() {
        
return name;
    }

    
public Person getPerson() {
        
return person;
    }

    
public Collection getCollection() {
        
return collection;
    }

    
public void setPerson(Person person) {
        
this.person = person;
    }

}

在jsp页面中:

如果我们直接
<ww:property value="[0]"/>   输出com.founder.HomeAction@e3ffdf,com.opensymphony.xwork.DefaultTextProvider@d402dd]
<ww:property value="[1]"/>   输出

[com.opensymphony.xwork.DefaultTextProvider@d402dd]
一般我们在没有循环的情况下不用[0]  [1] 可以直接访问

<ww:property value="name"/>输出 
propertyOfAction

那么[0] [1] 有什么用呢,在循环中就体现出来了.

<ww:iterator value="collection" status="person">
            
<ww:if test="#person.first == true"> 
                [0] :
<ww:property value="[0]"/></br>
                [1] :
<ww:property value="[1]"/></br>
                [2] :
<ww:property value="[2]"/></br>
            
</ww:if>
</ww:iterator>
[0] :[com.founder.Person@b3a5a0, com.founder.HomeAction@e3ffdf, com.opensymphony.xwork.DefaultTextProvider@d402dd]
[1] :[com.founder.HomeAction@e3ffdf, com.opensymphony.xwork.DefaultTextProvider@d402dd]
[2] :[com.opensymphony.xwork.DefaultTextProvider@d402dd]
输出以上代码,说明在一层循环中我们要访问[1]表示action对象.和没有循环的[0]对应.


总结:

假如你用webworkNOUI标签,对于Value Stack,一般你不要考虑[1] [0]之类的.记住一点
如果在循环中action的collection属性时体内,用[1]可以访问action对象和对应的属性.

对于多层循环或复杂用法,我只能告诉你,你的设计有问题?重构Model代码吧.