[英]Velocity Templates variables and methods. Why does *this* syntax work and *that* syntax doesn't?
[英]Velocity templates - Syntax for passing variables to methods
我正在尝试基于数据库查找构建一个“友好的” email 消息,并且似乎无法确定以下内容的正确语法:
System.out.println(TagFunctions.getConstantValue(4, "val1", Integer.parseInt(selectedFiling.getRejectionReason())));
我意识到我可以在我的 class 文件中对此进行评估,但希望能够在不再次部署的情况下进行数据库更改。
我相信我在这里遗漏了一些花括号,但我尝试过的任何方法都没有奏效。
$tagFunctions.getConstantValue(4, "val1", $Integer.parseInt($selectedFiling.rejectionReason))
除非你这样做:
context.put("Integer", Integer.class);
那么$Integer
在您的模板中不是有效的引用。
请发布实际代码和/或堆栈跟踪。
没有更多信息,这是我的第一个猜测。 您是否正确填充上下文,以便可以在 TagFunctions 和 Integer 上调用 static 方法? 有关更多信息,请参阅此链接: http://velocity.apache.org/engine/devel/developer-guide.html#supportforstaticclasses
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.