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

  • 相关阅读:
    python 大小写转换函数
    linux 自学系列:GRUB引导程序
    linux 自学系列:退出linux命令
    dict 常用方法
    ln命令简单用法
    利用easy_install 工作效率提升起来
    linux 自学系列:touch 命令
    linux 改文件夹命令
    开机自动重启脚本
    multiprocessing 用法
  • 原文地址:https://www.cnblogs.com/widget90/p/12425751.html
Copyright © 2011-2022 走看看