struts2 迭代 list中的map

<%@ 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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值