我有以下 HashMap,我想对其进行迭代并打印值。我怎样才能在 Spring 做到这一点?
HashMap<Integer, HashMap<String, String>> hm = new HashMap<Integer, HashMap<String, String>>();
最佳答案
可以使用JSTL来迭代HashMap的HashMap。
导入标签库<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
.
尝试这样:
<c:forEach var="entry" items="${hm}">
Key: <c:out value="${entry.key}"/>
Value: <c:out value="${entry.value}"/>
<c:set var="hm1" value="${Value}">
<c:forEach var="entry" items="${hm1}"/>
Key1: <c:out value="${entry1.key}"/>
Value1: <c:out value="${entry1.value}"/>
</c:forEach>
</c:forEach>
关于java - Spring应用程序中JSP中HashMap的迭代HashMap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23352281/