Velocity模板:如何将#springMessage()的结果放入速度变量中

时间:2011-11-01 17:05:04

标签: java spring velocity template-engine

我有一个来自此声明的值:

#springMessage("count.french")

我需要附加到另一个字符串,如

#set ( $theCount = '5467 ' )

然后基本上我需要这样做

#set ( $countText = $theCount+#springMessage("count.french") )

但它并不喜欢。任何人都知道如何做到这一点?

2 个答案:

答案 0 :(得分:4)

创建临时变量应该像下面这样简单(注意引号):

#set ( $test = "#springMessage( $key )" )

然后,按照你想要的方式使用它,例如。将它连接到另一个字符串。

答案 1 :(得分:2)

尝试以下方法:

#set($dynamicProp = '#set( $countText = $theCount ' + '#springMessage(count.french' + ' )')
#evaluate($dynamicProp)
相关问题