Java $null 检查速度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3478638/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
$null check in velocity
提问by lucky
I came to know about null check using $null in velocity 1.6 through a resource updated by you. Resource: Reading model objects mapped in Velocity TemplatesBut I am facing so many challenges that there is no $null for null check in velocity as there is no documentation provided about this. Please provide me with documentation stating $null as valid for null check in velocity.
我通过您更新的资源了解了在 Velocity 1.6 中使用 $null 进行空检查。资源:读取映射到 Velocity 模板中的模型对象但我面临着如此多的挑战,以至于没有 $null 用于在 Velocity 中检查空值,因为没有提供关于此的文档。请向我提供说明 $null 对空值检查有效的文档。
Thanks in Advance lucky
提前致谢 幸运
回答by a_horse_with_no_name
To check if a variable is not null simply use #if ($variable)
要检查变量是否为空,只需使用 #if ($variable)
#if ($variable) ... do stuff here if the variable is not null #end
If you need to do stuff if the variable is null simply negate the test
如果您需要在变量为空的情况下做一些事情,只需否定测试
#if (!$variable) ... do stuff here if the variable is null #end