Reputation: 161
My template String is as following and i want to replace the value of $java.lang.Object.property
String tempString = "hi test message for velocity $java.lang.Object.property";
here i am passing context map as follow
VelocityContext context = new VelocityContext();
context.put("java.lang.Object.property", "1");
StringWriter message = new StringWriter();
mVelocityEngine.evaluate( context, message, "LOG", tempString);
why velocity engine is not able to replace the value of java.lang.Object.property from the template?
Please Help. Thanks in advance.
Upvotes: 2
Views: 1189
Reputation: 28101
Short Answer:
Don't use .
in your context names
Long Answer:
Velocity has special treatment for .
and I think it's actually trying to call
context.get("java").getLang().getObject().getProperty()
I'm not 100% sure of the syntax but perhaps you could try $['java.lang.Object.property']
or similar... probably best to check the velocity docs for how to access context variables via string/map lookup.
Another option is to add a map to the context and access via:
$map['java.lang.Object.property']
Upvotes: 3