我有一个哈希映射,其中包含项ID作为键,Item对象作为值。以下是伪代码 -
allItems : {
12: itemObj1 (id:12, name:myitem1)
13: itemObj2 (id:13, name:myitem2)
14: itemObj3 (id:14, name:myitem3)
}
在result.ftl上我需要迭代这个map并获取Item Object的值。我尝试过这种方法但无法从Item对象中获取值 -
<#list item?keys as it>
${it} = ${item.get(it)[name]}
</#list>
答案 0 :(得分:9)
我想你想要:
<#list allItems?keys as it>
${it} = ${allItems[it].name}
</#list>
答案 1 :(得分:1)
<#assign seq=["a","b","c"]>
<#list seq as l>
${l[1]}
// It will print b
${l[0]}
//It will print a
</#list>