Moon Moon - 11 months ago 40
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?


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)

Or if you want to iterate over a number range:

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