1

I am using velocity to replace string values in Java.

If my string is "${product_name} available at ${product_price}", then in velocity context, if the values corresponding to the parameters product_name and product_price are found then velocity engine will replace them. However, if not found, the placeholder will not change.

What i am trying is if there are no placeholder values, a default param value should be used. i.e. if product_name is not found in velocity context, default value provided should be used.

Is such facility provided in velocity? And if so, can anybody point me to the correct documentation.

  • 2
    Please, see this question: http://stackoverflow.com/questions/13872808/can-velocity-set-a-default-value-for-a-variable-when-no-value-found-in-velocityc. Though rather old, the answers are still valid as Velocity project is on hold. – MyBrainHurts Mar 29 '16 at 08:44

0 Answers0