【发布时间】:2017-07-31 15:05:39
【问题描述】:
我目前有以下结构:
List<List<ClusterEntry>> clusters = new ArrayList<List<ClusterEntry>>();
//fill clusters and the list in clusters
input.put("clusters", clusters);
clusters 描述了我的集群,而 cluster.get(i) 包含一个集群中的所有元素。 对于报告,我想使用 freemarker 将此结果输出到 .md 文件中 目标是拥有与集群一样多的列,并且在每一行中都有一个相应集群的条目。 这是我的 .ftl 代码:
<#list clusters as c> | Cluster ${c_index} |
<#list c[c_index] as entry> | ${entry.name} | </#list>
</#list>
但是,这会导致以下错误
The value you try to list is an extended_hash+string (package.ClusterEntry wrapped into f.e.b.StringModel), thus you must specify two loop variables after the "as"; one for the key, and another for the value, like <#... as k, v>).
如何正确访问该条目? 如果你已经在这里阅读这篇文章,我怎样才能用这个嵌套循环正确地实现我的列行结构?目前我认为这将是单独的行
【问题讨论】:
标签: java markdown freemarker