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

Categories

0 votes
359 views
in Technique[技术] by (71.8m points)

java - $null check in velocity

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

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

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...