EL learning diary (1)

xiaoxiao2021-03-05  23

After the Overview to JSP 2.0, the EL has officially incorporated one of the standard specifications. Therefore, as long as the Container supported Servlet2.4 / JSP2.0, EL can be used directly in the JSP page.

grammar

Main grammar structure $ {sessionscope.user.sex} All EL is ended with $ {start}. The above EL example is to obtain the user's gender from the range of Session. Also equivalent to JSP ScriptleTlets: user user = (user) session.getattribute ("user"); string sex = user.getsex ();

Operator with the [] operator

EL is provided. And [] Two operators access data. The following two sentences: $ {sessionscope.user.sex} $ {sessionScope.user ["sex"]} can also be mixed: $ {sessionscope.shoppingcart [0] .price} The results are the first item in ShoppingCart The price of items.

But there are differences in the following two cases:

1. The property name contains some special characters, such as. Or - or not the letter or number of symbols, you must use [] 2, [] to add variables.

转载请注明原文地址:https://www.9cbs.com/read-38460.html

New Post(0)