Velocity中判断是否为空

方法一:

使用 #ifnull()#ifnotnull() 
eg:#ifnull ($foo) 
要使用这个特性必须在velocity.properties文件中加入: 

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

方法二:

使用null工具isNull()判断 
eg:#if($null.isNull($foo)) 

猜你喜欢

转载自www.cnblogs.com/kunmomo/p/10179807.html