日期:2014-05-18  浏览次数:20614 次

关于list<map>型在jsp页面上显示的问题
我用的是strut2自带标签.
这是代码:
                         <s:iterator value="list" id="mymap">
 <tr>
 <td align="center"></td>
 <td align="center"><td>                      </tr>
 </s:iterator>
我只要迭代list就行,假设map是('1','xx'),('2','xx').....
我要在<td>里根据map的key把value输出,应该怎么写,试过很多方法了,都不对

------解决方案--------------------
2. 遍历Map:

例:<%

  HashMap months = new HashMap();

  months.put(“Jan.”,”January”);

  months.put(“Feb.”,”February”);

  months.put(“Mar.”,”March”);

  request.setAttribute(“months”,months);

  %>


  <logic:iterate id=”element” indexed=”index” name=”months”>

      <bean:write name=”index” />.

      <bean:write name=”element” property=”key” />:

      <bean:write name=”element” property=”value” /><br />

  </logic:iterate>




我的博客有详细介绍:http://blog.csdn.net/yyw6637/article/details/8777586