<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page import="java.util.*" %>
<%@ page import="com.user.pojo.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<%String contextPath = request.getContextPath(); %>
<title>My JSP 'index.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>
<%
HashMap map = new HashMap();
User user = new User();
user.setUserName("张三");
user.setPassword("123123");
map.put("user",user);
//HashMap map1 = new HashMap();
User user1 = new User();
user1.setUserName("李四");
user1.setPassword("888888");
map.put("user1",user1);
HashMap map1 = new HashMap();
User user2 = new User();
user2.setUserName("王五");
user2.setPassword("111111");
map.put("user2",user2);
User user3 = new User();
user3.setUserName("赵六");
user3.setPassword("000000");
map.put("user3",user3);
List list = new ArrayList();
list.add(map);
list.add(map1);
//request.setAttribute("map",map);
request.setAttribute("list",list);
%>
----------------------------
<table>
<s:iterator value="#request.list" id="l">
<s:set value="#l" name="map"></s:set>
<s:iterator value="#map.keySet()" id="id">
<tr><td>
<s:property value="#id"/></td>
<s:iterator value="#map.get(#id)">
<td><s:property value="userName"/></td>
<td><s:property value="password"/></td>
</s:iterator>
</tr>
</s:iterator>
</s:iterator>
</table>
</body>
</html>
分享到:
相关推荐
struts2迭代 Map List
struts2迭代
iteratot标签:对集合属性迭代(属性类型:List、Map、数组)。 append标签:将多个集合对象拼接在一起,组成一个新的集合。将多个集合使用一个标签完成迭代。 generatot标签:将指定的字符串按照规定的分隔符分解...
iteratot标签:对集合属性迭代(属性类型:List、Map、数组)。 append标签:将多个集合对象拼接在一起,组成一个新的集合。将多个集合使用一个标签完成迭代。 generatot标签:将指定的字符串按照规定的分隔符分解...
{4.15}Map的迭代}{90}{section.4.15} {4.15.1}字符统计}{91}{subsection.4.15.1} {5}格式化输入输出}{94}{chapter.5} {5.1}时间与日期}{94}{section.5.1} {5.1.1}各类时间日期转换}{94}{subsection.5.1.1} {...
list指令是一个迭代输出指令,用于迭代输出数据模型中的集合,list指令的语法格式如下: <#list sequence as item> ... </#list> 上面的语法格式中,sequence就是一个集合对象,也可以是一个表达式,但该表达式将返回...
20. List、Set、Map 之间的区别是什么? 9 21. HashMap 和 Hashtable 有什么区别? 10 22. 如何决定使用 HashMap 还是 TreeMap? 10 23. 说一下 HashMap 的实现原理? 10 24. 说一下 HashSet 的实现原理? 11 25. ...
20.List、Set、Map 之间的区别是什么? 21.HashMap 和 Hashtable 有什么区别? 22.如何决定使用 HashMap 还是 TreeMap? 23.说一下 HashMap 的实现原理? 24.说一下 HashSet 的实现原理? 25.ArrayList 和 ...
Collection是集合类的上级接口,继承与他的接口主要有Set 和List. Collections是针对集合类的一个帮助类,他提供一系列静态方法实现对各种集合的搜索、排序、线程安全化等操作。 10、&和&&的区别。 &是位运算符...
Collection是集合类的上级接口,继承与他的接口主要有Set 和List. Collections是针对集合类的一个帮助类,他提供一系列静态方法实现对各种集合的搜索、排序、线程安全化等操作。 13、&和&&的区别。 &是位运算符...