| java code | OGNL expression |
|---|---|
| list.get(0) | list[WEBSTUDY:0] |
| array[WEBSTUDY:0] | array[WEBSTUDY:0] |
| ((Muppet)list.get(0)).getName() | list[WEBSTUDY:0].name |
| array.length | array.length |
| list.size() | list.size |
| list.isEmpty() | list.isEmpty |
| java code | OGNL expression |
|---|---|
| List list = new ArrayList(3) | {1, 3, 5} |
| list.add(new Integer(1)); | |
| list.add(new Integer(3)); | |
| list.add(new Integer(5)); | |
| return list; | |
| List list = new ArrayList(2) | {"foo", "bar"}[WEBSTUDY:1] |
| list.add("foo"); | |
| list.add("bar"); | |
| return list.get(1); |
| java code | OGNL expression |
|---|---|
| map.get("foo") | map[WEBSTUDY:'foo'] |
| map.get(new Integer(1)); | map[WEBSTUDY:1] |
| Muppet muppet = (Muppet)map.get("Kermit"); | map[WEBSTUDY:'kermit'].age |
| return muppet.getAge() | |
| map.put("foo", "bar") | map[WEBSTUDY:'foo'] = 'bar' |
| map.size() | map.size |
| map.isEmpty() | map.isEmpty |
| java code | OGNL expression |
|---|---|
| Map map = new HashMap(2); map.put("foo", "bar"); map.put("baz", "whazzit"); return map; | #{"foo" : "bar", "baz" : 'whazzit" } |
| Map map = new HashMap(3); map.put(new Integer(1), "one"); map.put(new Integer(2), "two"); map.put(new Integer(3), "three"); return map; | #{1 : "one", "2" : 'two", "3" : 'three" } |
| Map map = new HashMap(2); map.put(kermit.getName(), kermit.getMother().getName()); map.put(oscar.getName(), oscar.getMother.getName()); return map; | #{ #kermit.name : #kermit.mother.name, #oscar.name : #oscar.mother.name } |
| ActionContext.getContext().getParameters().get("id") | #parameters[WEBSTUDY:'id'] |
| String name = muppet.getName(); Map map = ActionContext.getContext().getSession(); return map.get("muppet-"+name); | #session[WEBSTUDY:'muppet-'+ name] |
| session.put("muppet-kermit", muppet); | #session[WEBSTUDY:'muppet-kermit'] = muppet |
| Array-style notation | Shorthand notation |
|---|---|
| #parameters[WEBSTUDY:'id'] | #parameters.id |
| #request[WEBSTUDY:'id'] | #request.id |
| #application[WEBSTUDY:'config'] | #application.config |
| OGNL expression | 설명 |
|---|---|
| children.{name} | 모든 children의 이름들을 가지고 온다. children collection(Muppets)에서 names collection(Strings)로 데이터 변화 |
| children.{?#this.age > 2} | 2년 이상의 children을 필터한다. #this 평가되어지는 객체의 구분하는 특수한 변수 |
| children.{?#this.age <= 2}.{name} | 2년 이하의 필터된 children의 이름들을 프로젝트한다 |
| children.{name + ' -> ' + mother.name} | name -> motherName 의 형태를 가지는 스트링의 리스트를 프로젝트한다(?) |