日期:2014-05-19 浏览次数:20673 次
@RequestMapping(value = "test")
public String test(ModelMap mm){
Map mainMap = new HashMap();
for (int i = 0; i < 10; i++) {
Map childMap = new HashMap();
for(int j = 0 ; j < 20 ; j++){
childMap.put("key" + j, "value" + j);
}
Etuser user = new Etuser();
user.setId(i + ""); //这里已经为id赋值了
user.setLoginname("aaaaaaa");
user.setLastaccesstime(new Timestamp(System.currentTimeMillis()));
mainMap.put(user + "", childMap);
}
mm.put("mainMap", mainMap);
return "evertrip/diyquote/test";
}
<#list mainMap?keys as mainKey >
${mainKey.id}
</#list>
==> ${mainKey.id} [on line 32, column 17 in evertrip/diyquote/test.ftl]
----------
Java backtrace for programmers:
----------
freemarker.template.TemplateException: Expected hash. mainKey evaluated instead to freemarker.template.SimpleScalar on line 32, column 19 in evertrip/diyquote/test.ftl.
at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:136)
at freemarker.core.Dot._getAsTemplateModel(Dot.java:78)
<#list mainMap?keys as mainKey >
${mainKey}
</#list>