Moon Moon - 7 months ago 19
Java Question

How to use 'for' loop in velocity template?

I just googled for 'for loop', but it looks like velocity has 'foreach' only.

How do I use 'for loop' in velocity template?

Answer

There's only #foreach. You'll have to put something iterable on your context. E.g. make bar available that's an array or Collection of some sort:

#foreach ($foo in $bar)
    $foo
#end

Or if you want to iterate over a number range:

#foreach ($number in [1..34])
    $number
#end