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>
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>