我如何在freemarker模板中迭代:
Map<Foo, List<Bar>> map = new HashMap<>();
我试过这个,但没有运气
<#list map?keys as key>
<p>${key.blah()}</p>
<#list map[key] as values values>
<p>${value.bar()}</p>
</#list>
</#list>
您需要循环通过映射/哈希值:
<#list map?values as currentList>
<#list currentList as value>
<p>${value.bar()}</p>
</#list>
</#list>
包含哈希中所有变量(键值对中的值(的序列。