`
no_bao
  • 浏览: 309752 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

struts2使用s:iterator标签解析List<Map<String,Object>>,其中Object有List类型

阅读更多
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>   list中Map的Key值
    <s:iterator value="#l.arrList" status="ii" >   list中Map的sublist值
         <td> ${system_name}  </td>
         <td> ${summi}  </td>  sublist中Map的Key值
    </s:iterator>
<tr>
</s:iterator>  
</table>




----------------------------------------------------

输出数组:
定义: String[] propertyNames=new String[100]
<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)[0] != symbol">
<option value="<s:property value="compayFundCodeList.get(#index)[0]"/>">
<s:property value="compayFundCodeList.get(#index)[1]"/>
</option>
</s:if>
</s:iterator>
</select>
0
2
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics