Velocity 模板 - 将变量传递给方法的语法
我正在尝试基于数据库查找构建一条“友好”的电子邮件消息,但似乎无法确定以下内容的正确语法:
System.out.println(TagFunctions.getConstantValue(4, "val1", Integer.parseInt(selectedFiling.getRejectionReason())));
我意识到我可以在我的类文件中对其进行评估,但希望能够无需再次部署即可更改数据库。
我相信我在这里缺少一些大括号,但我尝试过的任何方法都不起作用。
$tagFunctions.getConstantValue(4, "val1", $Integer.parseInt($selectedFiling.rejectionReason))
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(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.
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))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非您这样做:
那么
$Integer
不是模板中的有效引用。Unless you did:
then
$Integer
is not a valid reference in your template.请发布实际代码和/或堆栈跟踪。
没有更多信息,这是我的第一个猜测。您是否正确填充了上下文,以便可以调用 TagFunctions 和 Integer 上的静态方法?有关更多信息,请参阅此链接:http://velocity.apache.org/ engine/devel/developer-guide.html#supportforstaticclasses
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