Jsp ---- EL expression, jspel

Source: Internet
Author: User

Jsp ---- EL expression, jspel

Concept:

Expression Language (EL) is a new function added in JSP 2.0. Using Expression Language, you can easily access the attribute content of a flag (four types of flag spaces are provided in JSP: page (pageContext), request, session, and application, this avoids many scriptlet code. The simple syntax for accessing: $ {attribute name} outputs the attribute content without using the expression language.
<% @ Page contentType = "text/html" pageEncoding = "UTF-8" %> 

Use Expression Language to output attribute content

<% @ Page contentType = "text/html" pageEncoding = "GBK" %> 

From the above we can see that the EL expression language can easily output attributes, making the code more concise.

If the property does not exist, null is automatically set "".. You can use an expression to output attributes or parameters of a specified range.

Built-in object definition in Expression Language

Attribute range

Attribute of the retrieved range

<% @ Page contentType = "text/html" pageEncoding = "GBK" %> 

Call methods of JSP built-in objects

<% @ Page contentType = "text/html" pageEncoding = "GBK" %> 

Receiving Request Parameters

<% @ Page contentType = "text/html" pageEncoding = "GBK" %> 

Receives a set of parameters using expressions.

 

<Html> 
param_values_demo.jsp
<% @ Page contentType = "text/html" pageEncoding = "GBK" %> By default, the expression outputs attributes in order: Order: page> request> session> application also supports set operations in the expression language, you can easily use expression language to output the content in Collection (sub-interface: List, Set) and Map sets. Set of output Collection Interfaces

<% @ Page contentType = "text/html" pageEncoding = "GBK" import = "java. util. * "%> 

Output Map set

When the Map set is output, the VALUE still needs to be found through the KEY

<% @ Page contentType = "text/html" pageEncoding = "GBK" %> <% @ page import = "java. util. * "%> 

 

 

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.