如何在速度模板中使用'for'循环? [英] How to use 'for' loop in velocity template?
本文介绍了如何在速度模板中使用'for'循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是用google搜索'for loop',但看起来速度只有'foreach'。
I just googled for 'for loop', but it looks like velocity has 'foreach' only.
如何在速度模板中使用'for loop'?
How do I use 'for loop' in velocity template?
推荐答案
只有 #foreach
。你必须在你的上下文中加入一些可迭代的东西。例如。 make bar
可用的是一个数组或某种 Collection
:
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
这篇关于如何在速度模板中使用'for'循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文