---
title: "struts2使用s:iterator标签解析List<Map<String,Object>>，其中Object有List类型"
author: "no_bao"
date: "2011-12-30T13:35:51Z"
tags: []
categories: ["编程语言"]
slug: "struts2-s-iterator-list-map-string-object-object-list"
draft: false
lastmod: "2012-12-13T16:48:50Z"
id: 1330419
url: "https://it586.iteye.com/blog/1330419"
---

struts2中action数据封装格式 


List<Map<String,Object>> list = new ArrayList<Map<String,Object>> ();
List<Map<String,Object>> sublist= new ArrayList<Map<String,Object>> ();

Map<String,Object> submap =new HashMap<String,Object>();
    submap.put("system_name", "system1");
    submap.put("summi", "50分钟");
 

Map<String,Object> submap1 =new HashMap<String,Object>();
    submap1.put("system_name", "system2");
    submap1.put("summi", "80分钟");
   

sublist.add(submap);
sublist.add(submap1);

Map<String,Object> map =new HashMap<String,Object>();
    map.put("day", "2011-09-01");
    map.put("normal", "err");
    map.put("arrList", sublist);

Map<String,Object> map1 =new HashMap<String,Object>();
    map1.put("day", "2011-09-02");
    map1.put("normal", "ok");
    map1.put("arrList", sublist);

list.add(map);
list.add(map1); 


接收jsp标签输出：

<table>
<s:iterator value="list" status="i" id="l">

<tr>
    <td>${i.index}</td>
    <td>${day}</td>   <span style="color:blue">list中Map的Key值</span>
    <span style="color:red"> <s:iterator value="#l.arrList" status="ii" ></span>   <span style="color:blue">list中Map的sublist值</span>
         <td> ${system_name}  </td>
         <td> ${summi}  </td>  <span style="color:blue">sublist中Map的Key值</span>
    <span style="color:red"> </s:iterator></span>
<tr>
</s:iterator>   
 </table>




----------------------------------------------------

输出数组:
定义: String propertyNames=new String
<select id="matchProperties" name="matchProperties">
<s:iterator value="propertyNames">
<option value="<s:property/>">
<s:property/>
</option>
</s:iterator>
</select>

输出List<String>:
初始select选中项，并且迭代fee=List<String> 
<select id="productFee" name="productFee" class="sel_style_w_180">
<s:iterator value="fee" status="dex">
<s:set name="index" value="#dex.getIndex()"/>
<option value="<s:property value="fee.get(#index)"/>"
<s:if test="productFee == fee.get(#index)">
selected="selected"
</s:if>
>
<s:property value="fee.get(#index)"/>
</option>
</s:iterator>
</select>

输出List<String>:

初始select选中项，并且迭代compayFundCodeList=List<String>

<select name="compayFundCodeList" id="compayFundCodeList" style="width:150px" onchange="goBrief(this)">
<s:iterator value="compayFundCodeList" status="dex">
<s:set name="index" value="#dex.getIndex()"/>
<s:if test="compayFundCodeList.get(#index) != symbol">
<option value="<s:property value="compayFundCodeList.get(#index)"/>">
<s:property value="compayFundCodeList.get(#index)"/>
</option>
</s:if>
</s:iterator>
</select>