1,数字循环
#foreach($i in [0..9])
$i
#end
2,dictionary 根据key获取value值
#set($key1="123")
$!dict.get_Item($key1)即可
因为$!dict.key与$!dict.get_Item(key)其实是一致的。
3,模版内定义变量并赋值
#set($key1="123")
4,调用C#类中的成员方法
1)在C#类中
nvelocity.AddKeyValue("template", this); 将此类对象赋给模版变量
2)在模版中
#foreach($item in $template.GetData($sql,$orderby,"1","10"))
<li>
$item.get_Item("columnName")
</li>
#end
3) 变量和常量在一起
${item.get_Item("save_path")}index.html