标签:try override entryset his password throw get extend hashmap
1.
public class MapAction extends ActionSupport{ private Map<String, User> map = new HashMap<>(); public Map<String, User> getMap() { return map; } public void setMap(Map<String, User> map) { this.map = map; } @Override public String execute() throws Exception { //方法一:通过Entry遍历<迭代Entry> for(Entry<String, User> entry : map.entrySet()) { System.out.println(entry.getKey()+":"+entry.getValue().getUsername()); } //方法二:通过Set集合遍历<迭代Set> for(String key: map.keySet()){ System.out.println(key + ":" + map.get(key).getPassword()); } return SUCCESS; } }
标签:try override entryset his password throw get extend hashmap
原文地址:http://www.cnblogs.com/tianhengblogs/p/6759188.html