我正在使用 foreach 迭代一个集合(权限),寻找特定的条件。如果我已经找到了所有需要的内容,不再需要继续循环,有没有一种方法可以退出循环?我刚开始接触 Velocity,试图理解这种奇怪的语言。
#foreach ($perm in $space.getPermissions())
#end
我正在使用 foreach 迭代一个集合(权限),寻找特定的条件。如果我已经找到了所有需要的内容,不再需要继续循环,有没有一种方法可以退出循环?我刚开始接触 Velocity,试图理解这种奇怪的语言。
#foreach ($perm in $space.getPermissions())
#end
Velocity的最新版本(1.6)包含一个语句 #break
https://velocity.apache.org/engine/1.6.2/user-guide.html#Loops
## list first 5 customers only
#foreach( $customer in $customerList )
#if( $velocityCount > 5 )
#break
#end
$customer.Name
#end