Search code examples
javatemplatescollectionsvelocity

How to get a list using java method in velocity template


I am trying to get a List instance in velocity template using:

#set($list = ${Foo.BarList}.getList())

but I am getting an error.

Foo.Barlist has a method of getList that returns a List


Solution

  • Remove the curly brackets which is not needed in velocity

    #set($list = $Foo.BarList.getList())
    

    Or move the right one after method call:

    #set($list = ${Foo.BarList.getList()})