开发者

Is there a way to break from a foreach loop in velocity?

I'm looking for a certain condition by using foreach to iterate through a collection (of permissions). So if I find all that I need and don't need to loop anymore, is there a way to break out of the loop? I am new to velocity and trying to grok this weird language.

#foreach ($perm in $space.getPermission开发者_Python百科s())  
#end


The latest version of Velocity (1.6) contains a statement #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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜