代码之家  ›  专栏  ›  技术社区  ›  fastcodejava

速度上的elseif问题

  •  1
  • fastcodejava  · 技术社区  · 15 年前

    我有这个速度模板。在一种情况下效果很好,但在另一种情况下效果不好。如果我移除 elseif 它工作得很好。有人遇到过这个吗?

    #if (some condition)
         ## Do something 
    #elseif
         ## Do something else
    #end
    
    3 回复  |  直到 15 年前
        1
  •  6
  •   はると    15 年前

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

    else 似乎是你需要的。

    #if (some condition)
         ## Do something 
    #else
         ## Do something else
    #end
    
        2
  •  3
  •   Irshad huMpty duMpty    10 年前

    如果你正在使用 #elseif 然后你应该确保你正在检查里面的一些情况 #埃尔塞夫 陈述。

    例如:-

    #if (some condition)
         ## Do something 
    #elseif (some condition)
         ## Do something
    #else
         ## Do something else
    #end
    
        3
  •  0
  •   Mukti Desai    10 年前

    你可以这样说: 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
    

    (if elseif-…..-else梯段长度可以很长)