Struts 2 OGNL Syntax for Collections
Howto: Setting and getting values in a collection via OGNL in Struts 2
in geronimo, java, struts2
For Lists
- In Java code:
List list = new ArrayList(3); list.add("one"); list.add("two"); list.add("three"); - In OGNL, it is equivalent to:
- To access it in JSP:
roperty value="list[1]">roperty> - Will output in HTML:
Value=two
For Maps
- In Java code:
Map map = new HashMap(3); map.put("one", "uno"); map.put("two", "dos"); map.put("three", "tres"); - In OGNL, it is equivalent to:
- To access it in JSP:
Value=
roperty value="map['one']">roperty> - Will output in HTML:
Value=uno