Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 Templates But 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.

Thanks in Advance lucky

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
288 views
Welcome To Ask or Share your Answers For Others

1 Answer

To check if a variable is not null simply use #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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...