日期:2014-05-17  浏览次数:20764 次

关于jstl迭代这样一个Map集合,如何实现?Map<String, Map<String, Object>> 求高手,不懂别参合
public Map<String, Map<String, Object>> getleaveOvertimeTrainingMap(
QueryFilter leaveFilter,QueryFilter overtimeFilter,QueryFilter tariningFilter) {
Map<String, Map<String, Object>> lotMap = new HashMap<String, Map<String, Object>>();
List<Leave> leaveList = this.findLeave(leaveFilter);
Map<String, Object> leaveMap=new HashMap<String, Object>();
for(Leave leave: leaveList){
leaveMap.put(leave.getId(), leave);
}
System.out.println("请假人数"+leaveMap.size());
lotMap.put("leave", leaveMap);
List<Overtime> overtimeList=this.findOvertime(overtimeFilter);
Map<String,Object> overtimeMap = new HashMap<String,Object>();
for(Overtime overtime:overtimeList){
overtimeMap.put(overtime.getId(), overtime);
}
System.out.println("加班人数"+overtimeMap.size());
lotMap.put("overtime", overtimeMap);


return lotMap;
}
在页面用jstl迭代

------解决方案--------------------
<c:forEach var="map" items="${lotMap}">
<c:forEach var="map1" items="${map.value}">
<c:if test="${map.key}=='leave'">
${map1.key}<!-- 第几个leave.getId() -->
<c:set var="leave" value="${map1.value}"></c:set> 
${leave.属性名}
</c:if>
<c:if test="${map.key}=='overtime'">
${map1.key}<!-- 第几个overtime.getId() -->
<c:set var="overtime" value="${map1.value}"></c:set> 
${overtime.属性名}
</c:if>
</c:forEach>
</c:forEach>