2015-10-05 101 views
0
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和屬性列表?Freemarker打印列表地圖

在freemarker中打印地圖??????????

<#list mapFull as obj> 

    ClasseName 
     aa -- 1 
     aa -- 2 
     aa -- 3 

</#list> 

回答

0

正如你沒有描述Attribute類,我們假設它已經(至少)兩個字段名爲namecount,並與構造,以及相應的getter方法初始化。然後:

<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>