读书人

freemarker 遍列listlt;mapgt

发布时间: 2012-08-15 16:57:16 作者: rapoo

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>

读书人网 >Web前端

热点推荐