velocity判断空和null
来源:互联网 发布:鬼吹灯 盗墓笔记 知乎 编辑:程序博客网 时间:2024/06/05 18:58
判断是否为null有下面几种方法:
1. #if (! $foo) 判断$foo为空,判断非空为 #if ($foo)
2. 使用 #ifnull() 或 #ifnotnull()
#ifnull ($foo)
要使用这个特性必须在velocity.properties文件中加入:
userdirective = org.apache.velocity.tools.generic.directive.Ifnulluserdirective = org.apache.velocity.tools.generic.directive.Ifnotnull
3. 使用null工具判断
#if($null.isNull($foo))
注意这种方式特别有用,尤其你在需要这个判断作为一个判断字句时,比如我要你判断一个集合为null或为空时只能使用这种方式了:
$if ($null.isNull($mycoll) || $mycoll.size()==0)
=========================================
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
- velocity判断空和null
- Velocity判断null和空
- Velocity判断null跟空
- velocity模板判断null和空字符串方法
- velocity null和""判断
- Velocity学习--如何判断一个对象是否为空(null)
- Velocity学习--如何判断一个对象是否为空(null)
- velocity判断是否为null和 “”
- javascript判断空和null
- 关于velocity比较大小和判断空
- velocity判断空值
- MySql 判断null和空内容
- el表达式null和空的判断
- mysql 空值和null的判断
- 用StringUtils判断null 和 空串“”
- 判断字符串为空和null
- 业务参数判空和判断null
- Velocity中如何判断null
- android 代码混淆与反编译
- Enum源码分析
- CI框架SESSION使用
- 【MySQL 14】触发器after和before
- Unity Shader-后处理:简单的颜色调整(亮度,饱和度,对比度)
- velocity判断空和null
- 为什么使用maven
- 关于MPLL和UPLL的学习
- App缓存管理
- RunLoop的应用
- ListView
- 欢迎使用CSDN-markdown编辑器
- ORACLE 11g体系结构概述
- 如何提高CSDN博客排名