velocity 字符串相加

velocity 字符串相加
获取页面请求基础地址:

#set( $basePath = "$!{request.scheme}://$!{request.serverName}:$!{request.serverPort}$!{request.contextPath}/" )
String Literals
当你使用#set directive,String literal 封闭在一对双引号内。象下面:
#set( $directoryRoot = "www" )
#set( $templateName = "index.vm" )
#set( $template = "$directoryRoot/$templateName" )
$template
上面这段代码的输出结果为:
www/index.vm
但是,当string literal 被封装在单引号内时,它将不被解析:
#set( $foo = "bar" )
$foo
#set( $blargh = '$foo' )
$blargh
输出为:
bar $foo
上面这个特性可以通过修改 velocity.properties 文件的 stringliterals.interpolate = false 的
值来改变上面的特性是否有效。

你可能感兴趣的:(velocity 字符串相加)