什么是 Velocity
Velocity 是一个基于 Java 的模板引擎(template engine)。它允许任何人仅仅简单的使用模板语言(template language)来引用由 Java 代码定义的对象。
变量定义
#set($maxValue=5)
#set($name="Bob")
#set($arrayName=["element1","element2",...])
注释
## This is a single line comment.
#*
Thus begins a multi-line comment. Online visitors won't
see this text because the Velocity Templating Engine will
ignore it.
*#
静态引用输出
Velocity 遇到一个不能处理的引用时,一般它会直接输出这个引用 $email 的写法,页面上会显示为 $email。如下例,我们可以在 $ 后面加上一个 ! 号,那么就会输出空白:
<input type="text" name="email" value="$email"/>
<input type="text" name="email" value="$!email"/>
转义字符
如果 email 已定义了(比如它的值是 foo),而这里你却想输出 $email 这样一个字符串,就需要使用转义字符''。
## The following line defines $email in this template:
#set( $email = "foo" )
$email
\
\\
\\\

