Use of ongl and ongl
1. # symbol
- To access non-root object attributes, the Struts2 value stack is considered as the root object. Therefore, when accessing other non-root objects, you must add the # prefix. Actually, # is equivalent to ActionContext. getContext ();
- Used to filter and project sets, such as persons .{? # This. age> 20 }.
- Used to construct a Map. For example, # {'foo1': 'bar1', 'foo2': 'bar2'} in the example ′}.
2.% symbol
- % Is used to calculate the value of the OGNL expression when the flag property is of the string type. The following code constructs a Map:
1 <s: set name = "foobar" value = "# {'foo1': 'bar1', 'foo2 ': 'bar2'} "/> 2 <p> 3 The value of key" foo1 "is 4 <s: property value = "# foobar ['foo1']"/> 5 </p> 6 <p> 7 not used %: 8 <s: url value = "# foobar ['foo1']"/> 9 </p> 10 <p> 11 use %: 12 <s: url value = "% {# foobar ['foo1']}"/> 13 </p>
3. $ symbol (two aspects)
- Reference OGNL expressions in international resource files
- Reference OGNL expressions in the configuration file of Struts 2 Framework