Sturts2 iterator迭代标签迭代多层Map

本文个人总结:转载请表明出处:http://demojava.iteye.com/blog/810532

Sturts2 iterator迭代标签迭代多层Map
一层的Map Action
Map<Integer, String> map = new HashMap<Integer, String>();  
request.setAttribute("map", map); 
页面中:
<s:iterator value="#request.map" id="id">  
    <s:property value="key"/>  
    <s:property value="value"/>  
</s:iterator>
多层层的Map Action
private Map<String, Map<Long, Map<Long,UserInfo>>> map=new HashMap<String, Map<Long, Map<Long,UserInfo>>>();  
request.setAttribute("map", map); 
<s:iterator value="map.keySet()" status="sys"  id="map1"> 
  <tr>
    <td>
    <input type="checkbox" name = 'chk'   value='<s:property value="#map1.id"/>'  /><s:property value="#map1.systemCode.cname" />
    <s:iterator value="map.get(#map1).keySet()" status="model" id="map2">
     <input type="checkbox" name = 'chk'   value='<s:property value="#map2.id"/>'  /><s:property value="#map2.name" />//其中#map2.name表示UserInfo类中的属性
         <s:iterator value="map.get(#map1).get(#map2).values()" status="fun" id="map3">
      <input type="checkbox" name = 'chk'   value='<s:property value="#map3.id"/>'  /><s:property value="#map3.name"/>
         </s:iterator>
     </s:iterator>
   </td>
   </tr>
</s:iterator>

 

<s:iterator value="map"  status="st"  id="map1"> 
      <s:if test="#st.odd">
        <tr class="odd_row" >
      </s:if>
      <s:else>
        <tr class="even_row" >
      </s:else>
      <s:if test="key*ageInterval+ageInterval>100">
       <s:property value="key*ageInterval"/>    </s:if>
      <s:else>
       <s:iterator value="#map1.value" status="model" id="map2">
          <s:property value="#map2.value.year"/>
       </s:iterator>
       <s:property value="key*ageInterval"/>—<s:property value="key*ageInterval+ageInterval"/>
      </s:else>
     </td>
    </s:iterator>

你可能感兴趣的:(Blog)