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

Categories

0 votes
359 views
in Technique[技术] by (71.8m points)

"for" loop in velocity template

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

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

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...