Velocity 1.7 的一些新用法

HelGillum 8年前發布 | 1K 次閱讀 Java

Velocity 是一個非常不錯的 Java 模板引擎。

$velocityCount 的新用法

<table>
#foreach( $customer in $customerList )
    <tr><td>$foreach.count</td><td>$customer.Name</td></tr>
#end
</table>

$velocityHasNext 的新用法

#foreach( $customer in $customerList )
    $customer.Name#if( $foreach.hasNext ),#end
#end

退出foreach循環

## list first 5 customers only
#foreach( $customer in $customerList )
    #if( $foreach.count > 5 )
        #break
    #end
    $customer.Name
#end

同時引入多個文件

#include( "one.gif","two.txt","three.htm" )
 本文由用戶 HelGillum 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!