|
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ include file="/common/taglibs.jsp"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <[url=mailto:%@page]%@page import="com.stu.bean.StudentBean"%> <[url=mailto:%@page]%@page import="org.apache.struts.action.ActionErrors"%> <[url=mailto:%@page]%@page import="org.apache.struts.action.ActionMessage"%> <[url=mailto:%@page]%@page import="org.apache.struts.Globals"%> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'TestLogic1.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> logic:iterate使用:<p> <% HashMap months = new HashMap(); months.put("Jan.","January"); months.put("Feb.","February"); months.put("Mar.","march"); request.setAttribute("months",months); %> <logic:iterate id="element" indexId="i" name="months"> <bean:write name="i"/>. <bean:write name="element" property="key"/>: <bean:write name="element" property="value"/><p> </logic:iterate> <% HashMap h = new HashMap(); String vegetables[] = {"pepper","cucumber"}; String fruits[] = {"apples","orange","banana","cherry","watermelon"}; String flowers[]={"chrysanthemum","rose"}; String trees[]= {"window"}; h.put("Vegetables",vegetables); h.put("Fruits",fruits); h.put("Flowers",flowers); h.put("Trees",trees); request.setAttribute("catalog",h); %> <logic:iterate id="element" indexId="i" name="catalog"> <bean:write name="i"/>.<bean:write name="element" property="key"/>:<p> <logic:iterate id="elementValue" name="element" property="value" length="3" offset="1"> -----<bean:write name="elementValue"/><br> </logic:iterate> </logic:iterate> <% Vector animals = new Vector(); animals.addElement("Dog"); animals.addElement("Cat"); animals.addElement("Bird"); animals.addElement("Chick"); request.setAttribute("Animals",animals); %> <logic:iterate id="element" name="Animals"> <bean:write name="element"/><br> </logic:iterate><br> <logic:iterate id="element" indexId="i" name="Animals" offset="1" length="2"> <bean:write name="element"/><br> </logic:iterate><br> <logic:iterate id="header" collection="<%=request.getHeaderNames() %>"> <bean:write name="header"/><br> </logic:iterate> </body> </html>
|
一共有 0 条评论