The EL expression on the jsp page is treated as a string to solve the problem of not displaying the value.

Source: Internet
Author: User

The EL expression on the jsp page is treated as a string to solve the problem of not displaying the value.

In practice, we encountered the EL expression being processed as a string without correct parsing. Javaee5 used in the project at that time,

Web. xml

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" >

The EL expression does not parse and is processed as a string.

Later, I changed web. xml

<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

Redeploy and start tomcat. The EL expression is correctly parsed.

Further information was found:

This is a new feature of Jsp2.0:

2) Introduce Expression Language (EL)

One of the main features of JSP 2.0 is that it supports expression language ). The JSTL expression language can use the tag format to easily access JSP's hidden objects and JavaBeans components. The core tag of JSTL provides the process and loop control functions. Self-made tags also have the function of user-defined functions, so basically all functions that seriptlet can implement can be replaced by JSP. In JSP 2.0, we recommend that you use EL whenever possible to make the JSP format more consistent.

In <jsp-property-group> of web. xml, you can control whether a group of JSPs use EL. In each JSP, you can also specify whether the JSP uses EL. The isELIgnored attribute in page ctictive is used to specify whether to ignore the attribute. Format:

<% @ Page isELIgnored = "true | false" %>

If it is set to true, the expressions in JSP are treated as strings. For example, the following expression <p >$ {2000% 20} </p> outputs $ {2000% 20} When isELIgnored = "true }, when isELIgnored = "false", the output is 100. The default isELIgnored = "false" for Web containers ".

Although JSP 2.0 can completely use the expression language in JSP to avoid scriptlet, in actual programming, you should select the appropriate method according to the functional requirements of the program and the programming personnel's own conditions. JSP with the expression language is more convenient and regular, but it is slow to be called for the first time because tags need to be converted. Some programmers have a better understanding of Java, therefore, we are more accustomed to the programming method before JSP 1.2. Therefore, we should select appropriate programming methods in use.

That is to say, in javaee4, the default setting is <% @ page isELIgnored = "false" %>, while in javaee5, the default setting may be <% @ page isELIgnored = "true" %>,Therefore, in javaee5, you can set <% @ page isELIgnored = "false" %> On the jsp page to specify a normal EL resolution expression..

In the preceding jsp page, the EL expression is used as a string to handle the problem of not displaying the value. The solution is to share all the content with you. I hope to give you a reference, we also hope that you can support the customer's home.

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.