logic标签输出map和list

来源:互联网 发布:淘宝图库网站 编辑:程序博客网 时间:2024/06/05 22:46
  1. <%@ page language="java" pageEncoding="GBK"%>  
  2. <%@ page import="java.util.*"%>  
  3. <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>  
  4. <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>  
  5. <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>  
  6. <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>  
  7.   
  8. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
  9. <html:html lang="true">  
  10. <head>  
  11.     <title>LogicDemo06.jsp</title>  
  12. </head>  
  13.   
  14. <body>  
  15.     <%  
  16.       ArrayList  testList=new ArrayList();  
  17.       HashMap testMap1=new HashMap();  
  18.       testMap1.put("grade","七年级");  
  19.       testMap1.put("class","一班");  
  20.       testMap1.put("master","张三");  
  21.       testList.add(testMap1);  
  22.       HashMap testMap2=new HashMap();  
  23.       testMap2.put("grade","八年级");  
  24.       testMap2.put("class","二班");  
  25.       testMap2.put("master","张三");  
  26.       testList.add(testMap2);  
  27.       HashMap testMap3=new HashMap();  
  28.       testMap3.put("grade","九年级");  
  29.       testMap3.put("class","五班");  
  30.       testMap3.put("master","李四");  
  31.       testList.add(testMap3);  
  32.       request.setAttribute("testList",testList);  
  33.   
  34.     %>  
  35.     <logic:iterate id="element" indexId="ind" name="testList">  
  36.         <tr>  
  37.             <td>  
  38.                 <logic:iterate id="elementValue" indexId="idx" name="element">  
  39.                     <logic:equal name="elementValue" property="key" value="master">  
  40.                         <bean:write name="elementValue" property="value" />  
  41.                     </logic:equal>  
  42.                 </logic:iterate>  
  43.             </td>  
  44.   
  45.             <td>  
  46.                 <logic:iterate id="elementValue" indexId="idx" name="element">  
  47.                     <logic:equal name="elementValue" property="key" value="class">  
  48.                         <bean:write name="elementValue" property="value" />  
  49.                     </logic:equal>  
  50.                 </logic:iterate>  
  51.             </td>  
  52.               
  53.             <td>  
  54.                 <logic:iterate id="elementValue" indexId="idx" name="element">  
  55.                     <logic:equal name="elementValue" property="key" value="grade">  
  56.                         <bean:write name="elementValue" property="value" />  
  57.                     </logic:equal>  
  58.                 </logic:iterate>  
  59.             </td>  
  60.         </tr>  
  61.     </logic:iterate>  
  62.   
  63. </body>  
  64. </html:html> 

原创粉丝点击