I use velocity to merge a String(template) with field like
hi there I'am ${name},
And I'am ${age} old.
velocity merged the field ${name}
and ${age}
with a kind of hashtable:
velocityEngine.evaluate(context, writer, "", template);
context
is the hashtable(or better a VelocityContext
开发者_如何学运维type)
I want when Velocity can't find the field in the context he just delete them.
can i do this with a property or something?
Not sure if it is what you are asking, but if you want to prevent unassigned template vars from showing up in merged templates, you can use quiet notation by writing $!{name}
, there is also a global setting for that.
精彩评论