El Expression-1

Source: Internet
Author: User

EL provides. and [] Two operators to navigate the data. The following two represent the same meaning:

${sessionscope.user.sex}

Equals

${sessionscope.user["Sex"]}

. And [] can also be mixed at the same time, as follows:

${sessionscope.shoppingcart[0].price}

The return result is the price of the first item in ShoppingCart.

However, there are two situations in which the two are different:

(1) When the name of the property to be accessed contains some special characters, such as. or – such as symbols that are not letters or numbers, you must use [], for example: ${user. My-name}

The above is not the correct way, should be replaced by: ${user["My-name"]}

(2) We will consider the following situations:

${sessionscope.user[data]}

At this point, data is a variable, if the value of data is "sex", then the above example equals ${sessionscope.user.sex};

If the value of data is "name", it is equal to ${sessionscope.user.name}. Therefore, if you want to dynamically fetch the value, you can do it with the above method, but. cannot be dynamically evaluated.

El Expression-1

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.