快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

关于如何使用struts标签输出值为map的list


最近在一个项目中,要将一个list在客户端输出,而list里面的每个值不是bean,而是map,想好好久,想了个办法,可以实现,代码如下

  ArrayList  testList=new ArrayList();  HashMap testMap1=new HashMap();  testMap1.put("grade","七年级");  testMap1.put("class","一班");  testMap1.put("master","张三");  testList.add(testMap1);  HashMap testMap2=new HashMap();  testMap2.put("grade","八年级");  testMap2.put("class","二班");  testMap2.put("master","张三");  testList.add(testMap2);  HashMap testMap3=new HashMap();  testMap3.put("grade","九年级");  testMap3.put("class","五班");  testMap3.put("master","李四");  testList.add(testMap3);

    <table border="1" cellpadding="0" cellspacing="0" bordercolor="#0033CC" name="tableList">     <tr><td>master</td><td>class</td><td>grade</td></tr>            <logic:iterate id="element" indexId="ind" name="testList" >             <tr>                   <td>         <logic:iterate id="elementValue" indexId="idx" name="element">       <logic:equal name="elementValue" property="key" value="master">                    <bean:write name="elementValue" property="value"/>                     </logic:equal>      </logic:iterate>      </td>                                    <td> <logic:iterate id="elementValue" indexId="idx" name="element">      <logic:equal name="elementValue" property="key" value="class">                    <bean:write name="elementValue" property="value"/>                    </logic:equal>     </logic:iterate>     </td>                        <td><logic:iterate id="elementValue" indexId="idx" name="element">        <logic:equal name="elementValue" property="key" value="grade">                    <bean:write name="elementValue" property="value"/>                    </logic:equal>     </logic:iterate>       </td>            </tr>            </logic:iterate>    </table>
masterclassgrade还有更好的方式,欢迎交流,第一次在blog上发文,没有排版,请多见谅!



返回类别: 教程
上一教程: 利用反射从XML构造VO
下一教程: 学习JFreeChart(一)

您可以阅读与"关于如何使用struts标签输出值为map的list"相关的教程:
· 关于如何使用JdbcTemplate实现在WebLogic812,Oracle9i上的CLOB数据的写操作
· 在Struts中使用JavaBean和List(多行数据)类型属性
· 如何使用JSP连接DB2数据库
· 如何使用JSP访问MYSQL数据库
· 如何使用JSP+MYSQL创建留言本(二)
    微笑服务 优质保证 索取样品