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

  • 相关阅读:
    课程个人总结
    构建之法阅读笔记06
    构建之法读后感5
    第五周进度条
    提高自身能力
    活动图与状态机图
    对分析业务模型----类图的学习与认识
    需求分析工作的基本道理
    问题账户需求分析
    2016秋季个人阅读计划
  • 原文地址:https://www.cnblogs.com/widget90/p/12425751.html
Copyright © 2011-2022 走看看