Page History
In Velocity, you can declare a variable and set its value by using the #set directive, for example:
Code Block | ||
---|---|---|
| ||
##String
#set ($var = "abc")
##Boolean
#set($var2 = true)
##Value
#set($var3 = 10) |
The above example shows that $var has a string value, $var2 has a Boolean value, and $var3 has a numerical value. The #set directive can also set an array to a declared Velocity variable. To assign an array to a variable type, for example:
Code Block | ||
---|---|---|
| ||
#set($var = ["a", "b", "c"]) |