When a statement in Velocity returns null
, Velocity will output the statement itself. For example, if $searchResult.getProperty("Department")
is not set (is null
), the template will output $searchResult.getProperty("Department").
If you want to output "" (empty string) instead, you can specify the statement as $!statement
. In the example, when the statement is changed to $!searchResult.getProperty("Department")
(not the additional bang) and the property is not set, the template will output "" (empty string).