//第一种结构Map<K,<List<xxx>>>
<body>
<%
//显示map<String,List<Object>>
Map map = new HashMap<String,List<String>>();
List list = new ArrayList<String>();
list.add("list1-1");
list.add("list1-2");
list.add("list1-3");
List list2 = new ArrayList<String>();
list2.add("list2-1");
list2.add("list2-2");
list2.add("list2-3");
map.put("a",list);
map.put("b",list2);
// ActionContext.getContext().getValueStack().
request.setAttribute("map1",map);
%>
<%out.print("helloworld用于测试map和list值栈的遍历 "); %>
<s:iterator value="#request.map1" var="list">
map_key : <s:property value="#list.key"/></br>
<s:iterator value="#list.value" var="current">
list值:<s:property value="current"/></br>
</s:iterator>
</s:iterator>
</body>
//打印结果
helloworld用于测试map和list值栈的遍历
map_key : b
list值:list2-1
list值:list2-2
list值:list2-3
map_key : a
list值:list1-1
list值:list1-2
list值:list1-3
//第二种结构 List<Map<K,V>>
<%
List list = new ArrayList<Map<String,String>>();
Map map1 = new HashMap<String,String>();
map1.put("a","map1-1");
map1.put("b","map1-2");
Map map2 = new HashMap<String,String>();
map2.put("a","map2-1");
map2.put("b","map2-2");
map2.put("c","map2-3");
list.add(map1);
list.add(map2);
//放到root栈里面而非map栈中
// ActionContext.getContext().getValueStack().push(list);
request.setAttribute("list",list);
%>
<s:debug></s:debug>
<%out.print("helloworld用于测试map和list值栈的遍历 "); %>
<s:iterator value="#request.list" var="list1"></br>
<s:iterator value="#list1" var="map" ></br>
<s:property value="#map.key"/>
<s:property value="#map.value"/>
</s:iterator>
//打印结果
helloworld用于测试map和list值栈的遍历
b map1-2
a map1-1
b map2-2
c map2-3
a map2-1