logic标签输出map和list
来源:互联网 发布:淘宝图库网站 编辑:程序博客网 时间:2024/06/05 22:46
- <%@ page language="java" pageEncoding="GBK"%>
- <%@ page import="java.util.*"%>
- <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
- <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
- <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
- <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
-
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html:html lang="true">
- <head>
- <title>LogicDemo06.jsp</title>
- </head>
-
- <body>
- <%
- 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);
- request.setAttribute("testList",testList);
-
- %>
- <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>
-
- </body>
- </html:html>