Use of ongl and ongl

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.