$, %, #, {}, ^, And $ tags in OGNL

Source: Internet
Author: User

Use of $ in OGNL 1 .. in the international resource file, reference OGNL expression 2 .. in struts. in the xml file, reference the use of the "%" sign in the OGNL expression OGNL 1 .. you can use % {} to retrieve the Action object stored in the value stack and directly call its method 2 .. if Action inherits ActionSupport, you can use % {getText ('key')} In the page tag ')} get International Information # In OGNL use # In OGNL to retrieve the name of the object stored in the stack context. Example: attr is used to access its attributes in the order of request> session> application # attr. userName is equivalent to reading the userName attribute from three ranges until the request contains the Map # request of the attribute of the current HttpServletRequest. userName is equivalent to request. getAttribute ("userName") sessio N Map # session that contains the attributes of the current HttpSession. userName is equivalent to session. getAttribute ("userName") application contains the Map of the attributes of the current application's ServletContext # application. userName is equivalent to application. getAttribute ("userName") parameters contains the Map # parameters of the current HTTP request parameter. id [0] is equivalent to request. when getParameter ("id") uses projection to obtain attributes and uses projection to obtain the username attribute of objects in the List, {} indicates a collection of stus. {username} indicates that it is flexible to retrieve all the username attributes of suts and form a new list using the OGNL expression to obtain the attributes selected, you can use both the selection technology and projection technology to obtain attributes. When you use the selection technology, # t His indicates the current element. question mark? All elements that meet the conditions are obtained. The up arrow ^ indicates the beginning, that is, the first data in the Qualified Data Index, so stus. {^ # this. grade> = 60 }. {username} outputs [zhangsan] note that the output text contains brackets, which indicates that it is a list. And stus .{? # This. grade> = 60}. {username} [0] output is a string, which is different. The dollar sign $ indicates the end, that is, take the last row of data in the Qualified Data Index, so stus. {$ # this. grade> = 60 }. {username} outputs the [Wang Wu] symbols: Question mark, top arrow, and dollar sign all return List

Related Article

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.