2
我得到了一个例子我可以通过Velocity中的属性名称访问吗?
#set($organizationId = $layout.getGroup().getOrganizationId())
我可以把它改写为
#set($organizationId = $layout.group.organizationId)
?
它会完全一样吗?
我得到了一个例子我可以通过Velocity中的属性名称访问吗?
#set($organizationId = $layout.getGroup().getOrganizationId())
我可以把它改写为
#set($organizationId = $layout.group.organizationId)
?
它会完全一样吗?
是的。在这里看到:Velocity User Guide - Property Lookup Rules其中指出:
作为一个例子,$customer.address
,该序列是
getaddress()
getAddress()
get("address")
isAddress()
为了更精确, Velocity User Guide - Case Substitution:
$data.getRequest().getServerName()
## is the same as
$data.Request.ServerName
但是用圆括号书写getter调用也是正确的,意味着什么似乎是对的,对吧? – Dims 2013-04-30 12:32:15
是的,我更新了这篇文章。 – 2013-04-30 12:35:15