struts2标签iterator
<!--
iterator说明
* 当前正在迭代的元素在栈顶
* 如果value属性不写,则默认迭代栈顶的元素
* value值如果为top,则也是迭代栈顶的元素
-->
<s:iterator value="#departmentList">
<tr class="TableDetail1 template">
<td><s:property value="dname"/></td>
<td><s:property value="description"/></td>
<td>
<s:a action="">删除</s:a>
<a href="saveUI.html">修改</a>
</td>
</tr>
</s:iterator>
<!--
list中含有list
-->
<!--
<s:iterator>
<s:iterator>
<s:property value="dname"/>
</s:iterator>
</s:iterator>
-->
<!--
list中含有map
-->
<!--
<s:iterator value="#list">
<s:iterator value="top">
<s:property value="key"/>
<s:property value="value.dname"/>
</s:iterator>
</s:iterator>
-->
<!--
map中含有list
-->
<!--
<s:iterator value="#maps">
<s:property value="key"/>
<!--
该迭代就是一个list
-->
<!--
<s:iterator value="value">
<s:property value="dname"/>
</s:iterator>
</s:iterator>
-->
相应的action的方法
//ServletActionContext.getRequest().setAttribute("departmentList", departmentList);
// List<List<Department>> lists = new ArrayList<List<Department>>();
// Department department1 = new Department();
// department1.setDname("department1_name");
// Department department2 = new Department();
// department2.setDname("department2_name");
// List<Department> departmentList1 = new ArrayList<Department>();
// departmentList1.add(department1);
// List<Department> departmentList2 = new ArrayList<Department>();
// departmentList2.add(department2);
// lists.add(departmentList1);
// lists.add(departmentList2);
//
// List<Map<String, Department>> lists2 = new ArrayList<Map<String,Department>>();
// Map<String, Department> map1 = new HashMap<String, Department>();
// map1.put("d1", department1);
// Map<String, Department> map2 = new HashMap<String, Department>();
// map2.put("d2", department2);
// lists2.add(map1);
// lists2.add(map2);
//
// Map<String, List<Department>> maps = new HashMap<String, List<Department>>();
// maps.put("list1", departmentList1);
// maps.put("list2", departmentList2);
// ActionContext.getContext().put("maps", maps);