Shamik
Shamik

Reputation: 7108

how to set a map value in velocity

I tried to define a map in velocity template using the following syntax. It did not work, does anyone know how to declare a map of constant values in velocity?

#set ($mymap = {"key" : "value" , "key2" : "value"})

EDIT: I am using 1.6.3 version of velocity

Upvotes: 10

Views: 15437

Answers (1)

serg
serg

Reputation: 111265

It worked for me. Maybe you have very old version of Velocity?

#set ($mymap = {"key" : "value" , "key2" : "value2"})

get: ${mymap.key} 
or:  ${mymap.get("key")}

Upvotes: 17

Related Questions