Freemarker-访问地图中特定键的值 [英] Freemarker - access value at a particular key in map
本文介绍了Freemarker-访问地图中特定键的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的Freemarker模板中有Map
变量.像我们在Java(map.get(<key>)
)中一样,如何获取映射中特定键的值.
I have Map
variable in my Freemarker template. How can I fetch a value at a particular key in the map, as we do in Java (map.get(<key>)
).
我知道如何在FTL中遍历映射的键和值.但是我想要一个没有迭代的解决方案,就可以使用Map
接口的Java get()
方法.
I know how to iterate through keys and values of a map in a FTL. But I want a solution without iteration, on the lines of Java get()
method of Map
interface.
推荐答案
map[dynamicKey]
或map.staticKey
(如果键是字符串).由于历史限制,如果键不是字符串,则map?api.get(nonStringKey)
.
map[dynamicKey]
or map.staticKey
if the key is a string. Due to historical limitations, if the key isn't a string, map?api.get(nonStringKey)
.
这篇关于Freemarker-访问地图中特定键的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文