我想在 JSP 中做以下事情for loop
- 我只想循环 HashSet 和 HashMap 并打印结果
private static HashMap<Long, Long> histogram = new HashMap<Long, Long>();
private static Set<Long> keys = histogram.keySet();
for (Long key : keys) {
Long value = histogram.get(key);
System.out.println("MEASUREMENT, HG data, " + key + ":" + value);
}
我正在使用 Spring MVC,所以我在我的model
model.addAttribute("hashSet", (keys));
model.addAttribute("histogram", (histogram));
在我的 JSP 页面中,我正在做类似的事情来模拟上述内容,JAVA code
但它给了我一个例外,即我的 JSP 页面有问题。
<fieldset>
<legend>Performance Testing:</legend>
<pre>
<c:forEach items="${hashSet}" var="entry">
Key = ${entry.key}, value = ${histogram}.get(${entry.key})<br>
</c:forEach>
</pre>
<br />
</fieldset>
我得到的例外 -
Caused by: javax.el.PropertyNotFoundException: Property 'key' not found on type java.lang.Long
at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:195)
at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:172)
at javax.el.BeanELResolver.property(BeanELResolver.java:281)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
谁能帮我解决这个问题?