freeMarker 遍历 list,map,listmap
生活随笔
收集整理的這篇文章主要介紹了
freeMarker 遍历 list,map,listmap
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
List
List<String> clientSourceData=new ArrayList<String>();clientSourceData.add("field字段");clientSourceData.add("title標(biāo)題");
ftl:
<#if clientSourceData?exists><#list clientSourceData as key> <tr><td>${key}</td></tr></#list></#if>
Map
Map<String,String> clientSourceData=new HashMap<String,String>();clientSourceData.put("field", "字段");clientSourceData.put("title", "標(biāo)題");
ftl:
<#if clientSourceData?exists><#list clientSourceData?keys as key> <tr><td>${key}</td><td>${clientSourceData[key]}</td></tr></#list></#if>
List<Map>
List<Map<String,String>> columns=new ArrayList<Map<String,String>>();for(int i=0;i<10;i++){Map<String,String> col=new HashMap<>();col.put("field", "字段"+i);col.put("title", "標(biāo)題"+i);columns.add(col);}
ftl:
<#list columns as col>{field : ${col["field"]},halign:'center',title : ${col["title"]},} </#list>
總結(jié)
以上是生活随笔為你收集整理的freeMarker 遍历 list,map,listmap的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php 接口安全解决方案,php接口数据
- 下一篇: python3数字类型分为_Python