现在的位置: 首页 > 综合 > 正文

使用HashMap的Struts例子

2014年03月23日 ⁄ 综合 ⁄ 共 922字 ⁄ 字号 评论关闭
 
例子如下:

<%@page import="java.util.*,java.text.*" %>
<%@ page contentType="text/html; charset=GB2312" %>
<%@ 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" %>
<%
       HashMap animals = new HashMap();
        animals.put(new Integer(1), "猫");

字串8

        animals.put(new Integer(2), "狗");
        animals.put(new Integer(3), "马");
        animals.put(new Integer(4), "兔子");
        animals.put(new Integer(5), "金鱼");
        request.setAttribute("animals", animals);
    

%>
<html>
<head>
<title>
6
</title>
</head>
<body bgcolor="#ffffff">
<h1>
JBuilder Generated JSP
</h1>

<logic:iterate id="animals2" name="animals">
<bean:write name="animals2" property="value" />
</logic:iterate>


</body>
</html>

 

抱歉!评论已关闭.