问题
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>)
).
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.
回答1:
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)
.
来源:https://stackoverflow.com/questions/39248560/freemarker-access-value-at-a-particular-key-in-map