本文来自:http://blog.sina.com.cn/s/blog_4b01279a0100hc6o.html
#if(${data} != null)
#end
结果Velocity解析时抛出了如下错误:
Caused by: org.apache.velocity.exception.ParseErrorException:Encountered "null" at generator file[line 7, column 27]
一查Velocity的语法说明,原来Velocity判断null和java是不一样的。
总体来说,判断是否为null有下面几种方法:
userdirective = org.apache.velocity.tools.generic.directive.Ifnull userdirective = org.apache.velocity.tools.generic.directive.Ifnotnull