velocity学习记录

一、引入文件

静态引入:#include("./footer.vm.html")

动态引入:#parse("./header.vm.html")

说明:./为view目录

设置布局页面:#set($layout="layout/default.vm")

二、自定义标签

三、toolbox

四、内置对象

$request,$response,$session

五、宏

六、技巧

velocity foreach跳出循环

#foreach($item in $!list)

       #set( $c = $velocityCount+(-1))
                   #if($velocityCount==3)
                       #break     ##这个可以运行!!
                      // #continue ##也可以运行
                  #end
 #end

跳出循环 用stop 而不是continue

  #break 跳出循环 循环以外代码继续执行。

  #stop 直接终止输出,循环以外代码终止执行。

 

 

 七、数字格式化

$number.format("#0.00", $val)

 

八、mergeTemplateIntoString

VelocityEngineUtils.mergeTemplateIntoString

 

九、遍历

遍历map

#foreach($param in ${paramValues.keySet()})  
    <tr>  
        <th>$param</th>  
        <td>${paramValues.get($param)}</td>  
   </tr>  
#end  

遍历list

#foreach($sal in ${salerList})  
    $sal.name  
#end  

 

参考资料:

velocity入门

velocity 显示List和Map方法

VELOCITY 数组操作

spring下配置一个新的velocity engine

velocity.properties配置说明

velocity学习(3)--velocity.properties 配置文件

velocity使用(一)--简介

posted @ 2016-10-21 16:57  风过无痕521  阅读(205)  评论(0)    收藏  举报