Iterate over an HashMap> with Struts 2

前端 未结 2 1236
伪装坚强ぢ
伪装坚强ぢ 2020-12-03 05:12

I am currently facing some difficulties with Struts2 and the s:iterate tag.

I want to display a label, which is the key in the HashMap, followed by a table (the valu

相关标签:
2条回答
  • 2020-12-03 05:31
    Map<String,List<String>> mapVo=new  HashMap<String,List<String>>();
    <s:iterator value="mapVo"  var="mapList" status="status">
     <table>
        <s:property value="#status.index"></s:property>
       <s:property value="key"></s:property>
       <s:iterator  value="mapList" var="item" status="rowstatus">
         <tr>
           item
         </tr>
       </s:iterator>
     </table>
    </s:iterator>
    
    0 讨论(0)
  • 2020-12-03 05:36
    <s:iterator value="map">
      <h3><s:property value="key" /></h3>
      <table>
      <s:iterator value="value">
        <tr><td><s:property /></td></tr>
      </s:iterator>
      </table>
    </s:iterator>
    

    The iterator of a map is Map.Entry which gets put on the value stack and has two accessors, getKey() and getValue(). Iterate over Entry printing the key, then iterate over the values printing the value. (The list item gets put on top of the value stack so s:property just prints the top.)

    0 讨论(0)
提交回复
热议问题