古詩詞大全網 - 成語查詢 - action 定義了壹個map 怎麽在頁面上調用

action 定義了壹個map 怎麽在頁面上調用

public static void outMapDefault(Map map) {

if (map == null) {

System.out.println("Map is NULL!");

return;

}

Iterator it = map.keySet().iterator();

while (it.hasNext()) {

Object o = (Object) it.next();

if (map.get(o) instanceof List) {

List l = (List) map.get(o);

System.err.println("Map.key:" + o.toString());

for (Object object : l) {

System.err.println("Map.values:" + object);

}

} else {

System.err.println("Map.key:" + o.toString() + "\n"

+ "Map.value:" + map.get(o).toString());

}

}

}

這是個控制臺輸出map的範例 自己寫的