璁塊棶Action涓殑涓涓睘鎬?/td> |
<s:property value="postalCode"/> |
鍦ㄦ鏋朵腑浼氱粡甯擱亣鍒板鐞嗛泦鍚?nbsp;Collections (Maps, Lists, and Sets), 涓嬮潰鍒楀嚭鍑犱釜浣跨敤select 鏍囩澶勭悊闆嗗悎鐨勫垪瀛? OGNL documentation 涔熷寘鎷澶氬垪瀛?
Syntax for list: {e1,e2,e3}. 榪欎釜璇硶鍒涘緩浜嗕竴涓寘鍚瓧絎︿覆“name1”錛?#8220;name2”鍜?#8220;name3”鐨凩ist錛屽茍涓旈夋嫨“name2”浣滀負榛樿鍊箋?br />
<s:select label="label" name="name" list="{'name1','name2','name3'}" value="%{'name2'}" />
Syntax for map: #{key1:value1,key2:value2}. 榪欎釜璇硶鍒涘緩浜嗕竴涓狹ap閿煎闆嗗悎錛?#8220;foo”瀵瑰簲“foovalue”錛?#8220;bar”瀵瑰簲“barvalue”錛?br />
<s:select label="label" name="name" list="#{'foo':'foovalue', 'bar':'barvalue'}" />
鍒ゆ柇涓涓厓绱犳槸鍚﹀瓨鍦ㄤ簬涓涓泦鍚堜腑錛屼嬌鐢╥n 鎴?not in 鎿嶄綔銆?br />
<s:if test="'foo' in {'foo','bar'}">
muhahaha
</s:if>
<s:else>
boo
</s:else>
<s:if test="'foo' not in {'foo','bar'}">
muhahaha
</s:if>
<s:else>
boo
</s:else>
閫夋嫨闆嗗悎鐨勪竴涓瓙闆嗭紙涔熷彨鎶曞獎錛夛紝鍙互浣跨敤閫氶厤絎︼細
渚嬪錛岃幏寰椾漢鐨勪翰灞為泦鍚堜腑涓虹敺鎬х殑涓涓瓙闆?/p>
person.relatives.{? #this.gender == 'male'}
Lambda Expressions
OGNL supports basic lamba expression syntax enabling you to write simple functions.
(Dedicated to all you math majors who didn't think you would ever see this one again.)
Fibonacci: if n==0 return 0; elseif n==1 return 1; else return fib(n-2)+fib(n-1);
fib(0) = 0
fib(1) = 1
fib(11) = 89
How the expression works
The lambda expression is everything inside the square brackets. The #this variable holds the argument to the expression, which in the following example is the number 11 (the code after the square-bracketed lamba expression, #fib(11)).
<s:property value="#fib =:[#this==0 ? 0 : #this==1 ? 1 : #fib(#this-2)+#fib(#this-1)], #fib(11)" />