在 Velocity 中跳出 foreach 循环 [英] Breaking out of a foreach loop in Velocity
本文介绍了在 Velocity 中跳出 foreach 循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用
#if( $velocityCount > 5 )
#break
#end
中断我的 foreach
循环,但它没有中断,而是在输出中打印 #break
.
to break my foreach
loop, but its not breaking instead it is printing #break
in the output.
我也试过:
#foreach($item in $group.shipItems)
#if( $velocityCount > 5 )
#item.break
#end
#end
这里也是打印 #item.break
而不是打破循环.
Here also it is printing #item.break
instead of breaking the loop.
推荐答案
如果您使用的是 1.6 版,那么 #break
就足够了.这让我觉得您使用的是 1.4 或 1.5.还是您看到了一些错误?
If you are using version 1.6, then #break
should suffice. This makes me think you are using 1.4 or 1.5. Or are you seeing some errors?
如果您使用的是 1.7 版,#break
应该仍然有效,但您可以具体操作
If you are using version 1.7, #break
should still work, but you could be specific and do
#foreach($item in $group.shipItems)
#if( $foreach.count > 5 )
#break($foreach)
#end
#end
请养成提问时指定版本的习惯.
Please make it a habit to specify version when asking questions.
这篇关于在 Velocity 中跳出 foreach 循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文