freemarker中循环list中的map问题
我在后台传过来一个list,list中是我存的map结果集,请问怎么用freemarker循环出map中的结果呢...
我在后台传过来一个list,list中是我存的map结果集,请问怎么用freemarker循环出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>
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>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询