2010-10-06 69 views
1

我有这个速度模板。它在一种情况下工作正常,但不在另一种情况下。如果我删除elseif它工作正常。有没有人遇到过这个?问题elseif在速度

#if (some condition) 
    ## Do something 
#elseif 
    ## Do something else 
#end 

回答

5

我不知道速度,但通常使用elseif第二个条件。

else似乎是你所需要的。

#if (some condition) 
    ## Do something 
#else 
    ## Do something else 
#end 
+0

这是正确的。正确的语法是#elseif(othercondition),或者只使用#else。 – 2010-10-10 04:27:38

0

您可以参考这个: Apache Velocity User Guide

基本上它具有根据以下情况之一去:

#if (condition) 
    ##do something 
#end 

#if (condition) 
    ##do something 
#else 
    ##do something 
#end 

#if (condition) 
    ##do something 
#elseif (condition) 
    ##do something 
#else 
    ##do something 
#end 

(如果 - elseif的-....-其他梯子长度可以很长)

1

如果您使用的是#elseif语句,那么您应该确保您正在检查中的某些条件声明。

如: -

#if (some condition) 
    ## Do something 
#elseif (some condition) 
    ## Do something 
#else 
    ## Do something else 
#end