OGNL表达式语言 转
关键字: ognl表达式语言 转OGNL表达式语言
一 常量
|
Char |
‘a’ |
|
String |
‘hello’ 或 “hello” 单个字符 /”a/” |
|
Boolean |
true | false |
|
Int |
123 |
注意:string可以用单引号也可以用双引号。但是单个字母 如’a’与”a”是不同的,前者是char, 后者是string。
<ww:property value=”\”a\””> 或<ww:property value’”a”’>
二 操作符号
|
+ - * / mod |
1+1 ‘hello’+’world’
|
|
++ -- |
foo++ |
|
== != |
|
|
in not in |
foo in aList |
|
= 赋值 |
foo=1 |
三 方法调用
class Muppet{
int fun();
}
调用:fun()-10
四 访问静态方法和变量
@some.pkg.SomeClass@CONSTANTS
@some.pkg.SomeClass@someFun()
五 context
|
ActionContext().getContext().getSession().get(“kkk”) |
#session.kkk |
|
ActionContext().getContext().get(“person”) |
#person |
# 符号相当于ActionContext.
ActionContext 中的主要对象: parameters, attr, request, session, application
六 集合操作
list & array访问
|
list.get(0) array[0] |
list[0] array[0] |
|
list.get(0).getName() |
list[0].name |
|
list.size() array.length |
list.size array.length |
|
list.isEmpty() |
list.isEmpty |
|
List list = new ArrayList() list.ad(“foo”); list.add(“bar”); |
{“foo”, “bar”} {1,2,3} |
Map
|
map.get(“foo”) |
map[‘foo’] 或 map.foo |
|
map.get(1) |
map[1] |
|
Map map = new HashMap() map.put(“k1”, “v1”); map.put(“k2”,”v2”); |
#{“k1”:”v1”, “k2”:”v2”} |
七 筛选 与 投影
筛选 collection.{? expr }: #this 代表当前循环到的object
投影 collection.{ expr }
|
children.{name} |
(投影)得到 Collection<String> names, 只有孩子名字的list |
|
children.{?#this.age>2} |
(筛选)得到 collection<Person> age>2的记录 |
|
children.{?#this.age<=2}.{name} |
先筛选再投影 |
|
children.{name+’->’+mother.name} |
(筛选)得到元素为 str->str 的集合 |
NOTE : #的三种用途
1. 引用 ActionContext 中的object #person
2. 动态创建map #{1:’a’, 2:’b’}
3. 对集合进行筛选(#this) #this
发表评论
最近加入圈子
最新评论
-
base64Encode 与 base64D ...
...
-- by wdnntech -
java + ajax 视频 聊 ...
LZ有没有资料下载啊?
-- by jacky68147527 -
windows 播放 flash 没有 ...
:lol: :lol: 太有才了,我现在也碰到这种问题,试 ...
-- by wangyazhen -
Taobao 图片
我的陶宝店新开张 http://shop35481777.taobao.com/ ...
-- by pxysea -
备份恢复DB2数据库步骤
备份为什么要进行在线增量备份?在线意味者备份的时候,允许其他的连接,而不用停掉数 ...
-- by pxysea







评论排行榜