Freemarker遍历Map一些注意点

来源:互联网 发布:淘宝买东西有限额吗 编辑:程序博客网 时间:2024/06/03 16:15
测试发现:
Map<Integer,String>类型无法遍历,需要后台处理传递的map是Map<String,String>格式的。


取值情况失败如下:

1、<#if appMap?exists>
      <#list appMap?keys as key>
           key:${key}:value:${appMap.get(key)}
       </#list>
   </#if>
2、<#list testMap.keySet() as testKey>
       <option value="${testKey}" >
        ${testMap.get(testKey)}
     </option>
</#list>


!!!map.keySet is undefined是无法识别的。
!!!map.get is undefined也是无法识别的。


取值成功如下:
<#list map?keys as key>
   ${key} : ${map[key]}<br/>

</#list>


以上,欢迎加QQ1005113939交流,请各位大佬多多指教。

原创粉丝点击