任何人都可以向我解释如何在下面的示例中使用 jSTL 分别迭代此 map 的部门和报告。
Map<String, List<Object>> map = new HashMap<String, List<Object>>();
List<EmployeeDeparment> department = Emp.getEmployeeDepartment(EmployeeId);
map.put("department", department);
map.put("allreportingTo", allreportingTo);
map.put("alldepartments", alldepartments);
request.setAttribute("map", map);
最佳答案
如下图:
<c:forEach var="entry" items="${map}">
Key: <c:out value="${entry.key}"/>
Value: <c:out value="${entry.value}"/>
</c:forEach>
使用如下键从 map 中获取列表值:
${map.department}
您可以遍历列表,如下所示:
<c:forEach items="${map.department}" var="element">
<tr>
<td>${element.deptName}</td>
</tr>
</c:forEach>
关于java - 如何使用 jSTL 迭代 map ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22705107/