当前位置: 代码迷 >> Web前端 >> freemarker 遍列list<map>
  详细解决方案

freemarker 遍列list<map>

热度:184   发布时间:2012-08-15 16:57:16.0
freemarker 遍列list<map>
Java代码:

List list = new ArrayList();
Map map1 = new HashMap();
map1.put("phone", "13655555555");
map1.put("email", "admin@vip.com");
map1.put("address", "china");
list.add(map1);

Map map2 = new HashMap();
map2.put("phone", "13888888888");
map2.put("email", "china@vip.com");
map2.put("address", "beijing");
list.add(map2);




test.ftl文件:

<#list list as map>
<#list map?keys as itemKey>
     <#if itemKey="phone">
     Phone:${map[itemKey]}
     </#if>
     <#if itemKey="email">
     Email:${map[itemKey]}
     </#if>
     <#if itemKey="address">
     Address:${map[itemKey]}
     </#if>
</#list><br/>
</#list>
  相关解决方案