zoukankan      html  css  js  c++  java
  • velocity判断字段为空

    方法 1: 对null和false有效

    #if( ! $car.fuel )


    方法 2: 对null和""有效
    #if( "$!car.fuel" == "" )
    如果判断字段为空:
    #if( "$car.fuel" == "" )


    组合 方法 1 and 2,判断字段只能是null
    #if ((! $car.fuel) && ("$!car.fuel" == ""))


    方法 4: 使用工具检测,详见:http://wiki.apache.org/velocity/NullTool
    #if( $null.isNull($car.fuel) )


    方法 5: 使用自身方法检测
    #if( $car.fuelEmpty )
    car类实现isFuelEmpty()方法即可
    public boolean isFuelEmpty()
    {
      // return true if fuel is empty.
    }


    方法 6: 使用自定义指令. cf. IfNullDirective, IfNotNullDirective
    #ifnull( $car.fuel )
    #ifnotnull( $car.fuel )
    必须在velocity.properties.中注册:
    userdirective = org.apache.velocity.tools.generic.directive.Ifnull
    userdirective = org.apache.velocity.tools.generic.directive.Ifnotnull

    详见:http://wiki.apache.org/velocity/CheckingForNull


    ————————————————
    版权声明:本文为CSDN博主「猿敲月下码」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/thc1987/article/details/52091843

  • 相关阅读:
    HDU 4069 Squiggly Sudoku
    SPOJ 1771 Yet Another NQueen Problem
    POJ 3469 Dual Core CPU
    CF 118E Bertown roads
    URAL 1664 Pipeline Transportation
    POJ 3076 Sudoku
    UVA 10330 Power Transmission
    HDU 1426 Sudoku Killer
    POJ 3074 Sudoku
    HDU 3315 My Brute
  • 原文地址:https://www.cnblogs.com/widget90/p/12425751.html
Copyright © 2011-2022 走看看