![](/img/trans.png)
[英]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.