Velocity Template #set查询

时间:2013-01-21 11:19:44

标签: java templates velocity

我正在尝试使用#set并声明变量,但不知道为什么它不起作用。以下是我的代码:

#set( $emailContent = '<tr>
  <td style="color:#000;font-size:12px;line-height:16px;font-family:Arial;text-align:left;padding-top:15px" >
    <p style="font-size:12px;padding-top:15px;padding-bottom:15px">
        $userFirstName,<br /><br />
        Your sample account has been unlocked by your administrator. You should now be able to log back into your account. If you have further difficulty logging in, use the "Forgot password" link on the login page or contact your administrator for assistance.
    </p></td>
</tr>' )

我想知道在使用#set之前在服务器端声明$ emailContent很重要。

请帮忙。

1 个答案:

答案 0 :(得分:1)

不,在使用#set之前,你不必在java中声明它。但是你用它的方式,听起来好像不是一切都是“服务器端”,应该是这样。 Velocity在服务器上处理,而不是在客户端上处理。此外,并非每个版本的Velocity都支持多行字符串文字(如您的示例所示)。确保您使用的是最新版本。