velocity

velocity

velocity

v velocity简介

v velocity的使用方法

v 参考文献

velocity简介

VelocityASF下的一个优秀模板引擎

velocity的使用

v 取变量

  $             $customer  二级的$customer.Name

           多级类推

 

v 循环

#foreach( $mud in $mudsOnSpecial )

#end

$mud临时声明的变量 $mudsOnSpecial 集合

Velocity使用

v 对象的方法调用

$customer.hasPurchased($mud)

v 页面设置变量

  #set( $a = "Velocity" )

v 注释

    ##  单行注释

    #* *#多行注释

 

 

 

Velocity的使用

v 变量名称

alphabetic (a .. z, A .. Z)

numeric (0 .. 9)

hyphen ("-")

underscore ("_")

例如

 $foo          $mudSlinger
 $mud-slinger        $mud_slinger
 $mudSlinger1

 

Velocity的使用

 $customer.address

 这个取属性 如果点后是小写的,他查找的是这么干

getaddress()

getAddress()

get("address")

isAddress()          

 

Velocity的使用

属性查找

$customer.Address

getAddress()

getaddress()

get("Address")

isAddress()

Velocity的使用

索引方法

$foo[0]          ## $foo takes in an Integer look up

$foo[$i]         ## Using another reference as the index

$foo["bar"]   ## Passing a string where $foo may be a Map

点号取值

$foo.bar[1].junk

$foo.callMethod()[1]

$foo["apple"][4]

Velocity的使用

索引赋值

#set($foo[0] = 1)

 #set($foo.bar[1] = 3)

#set($map["apple"] = "orange")

{}的用法

${mudSlinger}

${customer.Address}

${purchase.getTotal()}

 

$!{email} 如果为空不显示

Velocity的使用

v $bar.bogus ## $bar does not provide property bogus, Exception

v $bar.foo.bogus ## $bar.foo does not provide property bogus, Exception

v  $bar.retnull.bogus ## cannot call a property on null, Exception

Velocity的使用

If / ElseIf / Else   用法

#if( $foo < 10 )

<strong>Go North</strong>

#elseif( $foo == 10 ) <strong>Go East</strong>

 #elseif( $bar == 6 ) <strong>Go South</strong>

 #else <strong>Go West</strong>

 #end

 

Velocity的使用

 逻辑符

  &&  ||  !

 包含

  #include( "one.txt" )

  #include( "one.gif","two.txt","three.htm" )

  #include( greetings.txt", $seasonalstock )

 

#parse( "me.vm" )

  parse 只能放一个参数

 

#break  跳出

Velocity使用

v 宏定义

#macro( d ) <tr><td></td></tr> #end

v 宏调用

#d()

 

Velocity的使用

参考文献

http://velocity.apache.org/engine/releases/velocity-1.7/user-guide.html

Velocity

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值