<s:iterator>应用
public String execute(){
list = new ArrayList<UserInfo>();
UserInfo userInfo = new UserInfo();
userInfo.setUsername("u1");
userInfo.setPassword("p1");
userInfo.setRoleInfo(new RoleInfo("r1"));
list.add(userInfo);
userInfo = new UserInfo();
userInfo.setUsername("u2");
userInfo.setPassword("p2");
userInfo.setRoleInfo(new RoleInfo("r2"));
list.add(userInfo);
}
<s:iterator value="list" var="var">
<s:property value="#var.username"/>
<s:property value="#var.password"/>
<s:property value="#var.roleInfo.rolename"/><br>
</s:iterator>
或者:
<s:iterator value="list">
<s:property value="username"/>
<s:property value="password"/>
<s:property value="roleInfo.rolename"/><br>
</s:iterator>
数组(普通属性)
public String execute(){
strs = new String[2];
strs[0] = "as";
strs[1] = "asd";
}
<s:iterator value="strs">
<s:property/><br>
</s:iterator>
或者:
<s:iterator value="strs" var="var">
<s:property value="var"/><br>
</s:iterator>
参考文献:
http://blog.csdn.net/xusongsong520/article/details/7945929