1. 程式人生 > >Velocity中判斷是否為空

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))