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

4 篇文章 0 订阅
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> [color=blue]list中Map的Key值[/color]
[color=red] <s:iterator value="#l.arrList" status="ii" >[/color] [color=blue]list中Map的sublist值[/color]
<td> ${system_name} </td>
<td> ${summi} </td> [color=blue]sublist中Map的Key值[/color]
[color=red] </s:iterator>[/color]
<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" οnchange="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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值