Visualforce 的表达式语法是:{! expression }
The expression syntax in Visualforce is: {! expression }
在渲染页面或使用值时,{! } 分隔符内的任何内容都会进行评估和动态替换。空格会被忽略。
结果值可以是原始值(整数、字符串等)、布尔值、sObject、控制器方法(例如操作方法)和其他有用的结果。
Anything inside the {! } delimiters is evaluated and dynamically replaced when the page is rendered or when the value is used. Whitespace is ignored.
The resulting value can be a primitive (integer, string, and so on), a Boolean, an sObject, a controller method such as an action method, and other useful results.
全局变量可以访问和显示系统值和资源,Visualforce可以使用20多种全局变量。
使用方法:{! $GlobalName.fieldName }
<apex:page>
<apex:pageBlock title="User Status">
<apex:pageBlockSection columns="1">
{! $User.FirstName } {! $User.LastName }
{! $User.FirstName & ' ' & $User.LastName }
{! $User.Username }
({! IF($User.isActive, $User.Username, 'inactive') })
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Visualforce 表达式不区分大小写,并且忽略 {! …} 内的空格。以下表达式效果一样:
{! $User.FirstName}
{!$USER.FIRSTNAME}
{! $user.firstname }
Visualfoece可以使用十多种函数
详细参照:Visualforce 函数引用
<apex:page>
<apex:pageBlock title="User Status">
<apex:pageBlockSection columns="1">
{! $User.FirstName } {! $User.LastName }
({! $User.Username })
<p> Today's Date is {! TODAY() } </p>
<p> Next week it will be {! TODAY() + 7 } </p>
<p>The year today is {! YEAR(TODAY()) }</p>
<p>Tomorrow will be day number {! DAY(TODAY() + 1) }</p>
<p>Let's find a maximum: {! MAX(1,2,3,4,5,6,5,4,3,2,1) } </p>
<p>The square root of 49 is {! SQRT(49) }</p>
<p>Is it true? {! CONTAINS('salesforce.com', 'force.com') }</p>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

<p>{! IF( CONTAINS('salesforce.com','force.com'),'Yep', 'Nope') }</p>
<p>{! IF( DAY(TODAY()) < 15,'Before the 15th', 'The 15th or after') }</p>