用Struts的iterate标签如何显示Map的键值

作者在 2006-12-10 02:41:00 发布以下内容

<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.util.*"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%
Map months=new HashMap();
months.put("Feb.","February");
months.put("Mar.","March");
request.setAttribute("months",months);
%>
<html>
<head>
<title>
map
</title>
</head>
<body bgcolor="#ffffff">
<h1>
map demo
</h1>
<logic:iterate id="element" indexId="index" name="months">
<bean:write name="index"/>
<bean:write name="element" property="key"/>
<bean:write name="element" property="value"/><br>
</logic:iterate>

</body>
</html>

默认分类 | 阅读 3530 次
文章评论,共0条
游客请输入验证码
文章分类
最新评论