Velocity templates - Syntax for passing variables to methods
I am trying to construct a "friendly" email message based on a database lookup and cannot seem to nail down the right syntax for the following:
System.out.println(TagFunctions.getConstantValue(4, "val1", Integer.parseInt(selecte开发者_开发技巧dFiling.getRejectionReason())));
I realize that I could just evaluate this within my class file, but the desire is to be able to make database changes without deploying again.
I believe that I am missing some curly braces here, but I nothing that I have tried has worked.
$tagFunctions.getConstantValue(4, "val1", $Integer.parseInt($selectedFiling.rejectionReason))
Unless you did:
context.put("Integer", Integer.class);
then $Integer
is not a valid reference in your template.
Please post the actual code and/or stack trace.
Without more information, here's my first guess. Are you populating the context properly such that you can call static methods on TagFunctions and Integer? See this link for more info: http://velocity.apache.org/engine/devel/developer-guide.html#supportforstaticclasses
精彩评论