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.
util. HashMap. get() method of HashMap class is used to retrieve or fetch the value mapped by a particular key mentioned in the parameter. It returns NULL when the map contains no such mapping for the key.
Freemarker does not provide a random number generator at the moment. You can implement a naive random number generator using the time ( . now ) as a seed, but it should never be a critical part of your program. Save this answer.
Comments: Comments are similar to HTML comments, but they are delimited by <#-- and --> . Comments will be ignored by FreeMarker, and will not be written to the output.
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)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With