jstl如何遍历存在map中的list

chuliuchu 2011-04-27 11:49:45
如题:数据结构如下
Map<String, List<GatherMess>> sMap=new HashMap<String, List<GatherMess>>();

List<GatherMess> gList=new ArrayList<GatherMess>();

GatherMess gatherMess=new GatherMess();

gatherMess.setUserName("zhang");
gatherMess.setMessNum(2);
gList.add(gatherMess);

gatherMess.setUserName("yang");
gatherMess.setMessNum(3);
gList.add(gatherMess);

sMap.put("sannong", gList);
...全文
300 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
小绵羊 2011-04-27
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 amos1989 的回复:]

引用 2 楼 amos1989 的回复:

Java code

<c:forEach items="${map}" var="m">
<c:forEach items="${m.list}" var="l">
//输出list的数据
</c:forEach>
</c:forEach>



<c:forEach items="${map}" var="m">
……
[/Quote]


+1000
amos1989 2011-04-27
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 amos1989 的回复:]

Java code

<c:forEach items="${map}" var="m">
<c:forEach items="${m.list}" var="l">
//输出list的数据
</c:forEach>
</c:forEach>
[/Quote]


<c:forEach items="${map}" var="m">
<c:forEach items="${m.value}" var="l">
//输出list的数据
</c:forEach>
</c:forEach>
amos1989 2011-04-27
  • 打赏
  • 举报
回复

<c:forEach items="${map}" var="m">
<c:forEach items="${m.list}" var="l">
//输出list的数据
</c:forEach>
</c:forEach>

chuliuchu 2011-04-27
  • 打赏
  • 举报
回复
自己顶
chuliuchu 2011-04-27
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 amos1989 的回复:]

引用 2 楼 amos1989 的回复:

Java code

<c:forEach items="${map}" var="m">
<c:forEach items="${m.list}" var="l">
//输出list的数据
</c:forEach>
</c:forEach>



<c:forEach items="${map}" var="m">
……
[/Quote]

你这个方法也不对,页面上没有数据,后来发现是我少写了个value导致,还是谢谢了

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧