[英]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:我正在尝试基于数据库查找构建一个“友好的” email 消息,并且似乎无法确定以下内容的正确语法:
System.out.println(TagFunctions.getConstantValue(4, "val1", Integer.parseInt(selectedFiling.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.我意识到我可以在我的 class 文件中对此进行评估,但希望能够在不再次部署的情况下进行数据库更改。
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.那么$Integer
在您的模板中不是有效的引用。
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?您是否正确填充上下文,以便可以在 TagFunctions 和 Integer 上调用 static 方法? See this link for more info: http://velocity.apache.org/engine/devel/developer-guide.html#supportforstaticclasses有关更多信息,请参阅此链接: http://velocity.apache.org/engine/devel/developer-guide.html#supportforstaticclasses
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.