閱讀817 返回首頁    go 小米 go 小米6


java以及jstl表達式中對HashMap的迭代

 

①java

entrySet()返回此映射所包含的映射關係的Set視圖,即key-value的set集合,類型是Set<Map.Entry<K,V>>

HashMap<String, Object> map = new HashMap<String, Object>();
map.put("001", "xy001");
map.put("002", "xy002");
Set<Map.Entry<String, Object>> entrySet = map.entrySet();
for (Map.Entry<String, Object> entry : entrySet)
{
System.out.println(entry.getKey() + "..." + entry.getValue());
}

 

②JSTL

<c:forEach items="${map}" var="entry">
 ${entry.key}:${entry.value}
</c:forEach>

 

 

最後更新:2017-04-02 15:15:33

  上一篇:go maven中引用JDK中的tools.jar
  下一篇:go jdk1.5新特性2之動態參數列表