首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Velocity判断null跟空

2012-10-09 
Velocity判断null和空velocityApache1、判断Velocity 是否为null???? 方法一 、 #ifnull() 或 #ifnotnull()?

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

热点排行