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