Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set a map value in velocity

Tags:

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

like image 728
Shamik Avatar asked Apr 08 '11 22:04

Shamik


1 Answers

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")}
like image 61
serg Avatar answered Jan 01 '23 23:01

serg