ftl中是这样写的:
<#list tables?keys as testKey>
${testKey}
</#list>
报错如下:
2015-11-3 17:24:26 freemarker.log.JDK14LoggerFactory$JDK14Logger error
严重: Template processing error: "Expression tables is undefined on line 563, column 8 in report.ftl."
Expression tables is undefined on line 563, column 8 in report.ftl.
The problematic instruction:
----------
==> list tables?keys as testKey [on line 563, column 1 in report.ftl]
----------
Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Expression tables is undefined on line 563, column 8 in report.ftl.
at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:125)
at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135)
at freemarker.core.BuiltIn$keysBI._getAsTemplateModel(BuiltIn.java:668)
at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94)
at freemarker.core.Environment.visit(Environment.java:221)
当Map里面的key 是Object(String,Integer,etc)等要通过以下的方式来得到
<#list testMap?keys as testKey>或者使用:
<#list testMap.keySet() as testKey>切记在webwork自带的freemarker中对Map中Key的定义为String类型(如果你想用${Map[key]}这样取值的话;如果用${Map.get(key}这样取值就可以用其他类型,如Map<Long,Object>),更高片本是否可以用其他类型本人未曾验证
<#list pager.map.get("m") as list>