Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I already posted a similar question a week ago on How to use 'for' loop in velocity template?.

So...basically I can't use 'for' loop in a velocity template.

Let's say I have a variable that holds integer 4. I want to display something four times using that variable. How do I do it in a velocity template?

question from:https://stackoverflow.com/questions/5735097/for-loop-in-velocity-template

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
375 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try to do it like this:

#set($start = 0)
#set($end = 4)
#set($range = [$start..$end])
#foreach($i in $range)
   doSomething
#end

The code has not been tested, but it should work like this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...