`
shuai1234
  • 浏览: 936256 次
  • 性别: Icon_minigender_1
  • 来自: 山西
社区版块
存档分类
最新评论

Velocity判断null和空

    博客分类:
  • java
 
阅读更多

1、判断Velocity 是否为null

     方法一 、 #ifnull() 或 #ifnotnull()

     Eg: #ifnull ($XXX)

     Warn:要使用这个特性必须在velocity.properties 文件中加入:

     userdirective = org.apache.velocity.tools.generic.directive.Ifnull
     userdirective = org.apache.velocity.tools.generic.directive.Ifnotnull

     方法二 、$null.isNull()
     Eg:#if($null.isNull())

     推荐使用方法二,特别是在判断集合对象为null时,灰常有用。



2、判断Velocity是否为空

      判断空:#if (! $xxx)
      判断非空: #if ($xxx)


3、更详细的介绍请参考:
     http://wiki.apache.org/velocity/VelocityNullSupport
     http://wiki.apache.org/velocity/CheckingForNull

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics