Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of Web basic EL expressions?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article is to share with you about the use of EL expressions in the basic version of Web. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

EL expression

EL (ExpressionLanguage) is the built-in expression language of JSP, which is used to access the context of the page and objects in different scopes, get the value of object properties, or perform simple operations or judgment operations. When EL gets some data, it automatically converts the data type.

The EL expression is used to do the output operation in the page instead of the JSP expression ().

The purpose of EL expressions is to make JSP easier to write and simplify jsp code.

EL expressions are used only to read data, not to modify it.

When using EL expressions to output data, output data if there is any, and nothing if null.

EL expression, which can greatly simplify the display of data on JSP pages. It is used to optimize data reading operations.

The main function of EL expressions is to get data from domain objects and output

Basic grammar

EL expressions are always placed in {} with a $prefix

${Identifier}

The first point: when the key output of the EL expression does not exist, the output is an empty string ""

The second point: the order in which EL expressions search for attributes in domain objects is pageContext,request,session,application

Objects in the fetched domain can use the object name directly and look up in the order from smallest to largest. For example, get an object named user in the domain

${user}

The property value of an object can be obtained directly through the object. property name "

${user.name}

Note: the attribute name here is the property value corresponding to the get and set methods, not the variable name in the object.

For example, if you get the value of the name attribute, there must be a getName () method in the object.

You can also get the properties of an object through "object [" property name "]".

${user ["name"]}

You can get the attribute in Map directly through the key of the attribute.

${map.key}

${map [key]}

Thank you for reading! This is the end of this article on "what is the use of EL expressions in the basic version of Web". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report