Freemarker iterating over hashmap keys

后端 未结 7 1288
梦毁少年i
梦毁少年i 2020-11-27 15:39

Freemarker has two collection datatypes, lists and hashmaps Is there a way to iterate over hashmap keys just as we do with lists?

So if I have a var with data lets s

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 16:06

    FYI, it looks like the syntax for retrieving the values has changed according to:

    http://freemarker.sourceforge.net/docs/ref_builtins_hash.html

    <#assign h = {"name":"mouse", "price":50}>
    <#assign keys = h?keys>
    <#list keys as key>${key} = ${h[key]}; 
    

提交回复
热议问题