今天在项目中遇到需要将后台传入的Map<String, List<Meeting>> dateGroup类型的集合在jsp中显示,刚开始还以为很麻烦,结果在网上查了一下原来如此简单,呵呵:
[b]<c:forEach items="${dateGroupMap}" var="dateGroup" >[/b]
<tr>
[b]<td width="20%" valign="bottom">${dateGroup.key[/b]}</td>
</tr>
[b]<c:forEach items="${dateGroup.value}" var="meeting">[/b]
<tr>
<td colspan="4"><hr></td>
</tr>
<tr height="20">
<td height="20">${meeting.startDate}
<c:if test="${not empty meeting.endDate}">
--${meeting.endDate}
</c:if>
</td>
<td height="20">${meeting.title}</td>
<td height="20">${meeting.location}</td>
<td height="20">${meeting.content}</td>
</tr>
</c:forEach>
</c:forEach>
本文介绍了一种简单的方法,用于在JSP页面上展示从后台传递过来的Map<String,List<Meeting>>类型的数据。通过使用JSTL标签库中的<c:forEach>标签,可以有效地遍历并显示这些数据。
844

被折叠的 条评论
为什么被折叠?



