Velocity判断null和空
velocityApache
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