List<Atribute> atributes= new ArrayList<>();
atributes.add(new Atribute("aa","1"));
atributes.add(new Atribute("aa","2"));
atributes.add(new Atribute("aa","3"));
Map<String, Object> mapOne = new HashMap();
mapOne.put("ClasseName", atributes);
Map mapFreemarker = new HashMap();
mapFreemarker.put("mapFull", mapOne);
如何在freemarker中打印mapOne和atributes列表?
在freemarker中打印地图??????????
<#list mapFull as obj>
ClasseName
aa -- 1
aa -- 2
aa -- 3
</#list>
答案 0 :(得分:0)
As you haven't described the Attribute
class, let's assume it has (at least) two fields named name
and count
and initialized with the constructor, and the appropriate getters. Then:
<ul>
[#list mapFull?keys as key]
<li>
${key}
<ul>
[#list mapFull[key] as val]
<li>${val.name} -- ${val.count}</li>
[/#list]
</ul>
</li>
[/#list]
</ul>