The solution to the problem that El expression in JSP page is treated as string and does not display value


When I practiced, I encountered the phenomenon that El expressions were treated as strings without proper parsing. Java ee5 used in the project at that time,


<web-app version="2.5" 
xsi:schemaLocation="" >

El expression is not parsed. It is treated as a string.

Later, we changed web.xml to

<web-app version="2.4" 

Redeploy, start tomcat, and the resulting El expression is parsed correctly.

After further investigation, we learned that:

This is a new feature of jsp2.0:

2) Introducing expression language (EL)

One of the main features of JSP 2.0 is that it supports expression language. JSTL expression language can use tag format to easily access JSP implicit objects and JavaBeans components. JSTL core tags provide flow and loop control functions. The self-made tag also has the function of custom function, so basically all the functions that can be realized by the seriptlet can be replaced by JSP. In JSP 2.0, it is recommended to use El as much as possible to make JSP format more consistent.

In the < JSP property group > of web.xml, you can control whether a group of JSPS use El or not. In each JSP, you can also specify whether the JSP uses El or not. The iselignored attribute in the page directive specifies whether to ignore. The format is:

<%@ page isELIgnored=”true|false”%>

If set to true, the expression in the JSP is treated as a string. For example, the following expression < P > ${2000% 20} < / P > is output as ${2000% 20} when iselignored = true, and 100 when iselignored = false. Web container default iselignored = false.

Although JSP 2.0 can make JSP use expression language completely and avoid scriptlet, in the actual programming, we should choose the appropriate way according to the functional requirements of the program and the conditions of the programmers themselves. JSP using expression language is more convenient and regular, but it will be slower when it is called for the first time due to the need to transform tags; some programmers are more accustomed to the programming method before JSP 1.2 because they know Java better, so they should choose the appropriate programming method according to local conditions in use.

That is to say, in Java ee4, the default setting is% @ page iselignored = “false”%, while in Java ee5, the default setting may be% @ page iselignored = “true”%,So in Java ee5, we can specify the normal resolution of El expression by setting <% @ page iselignored = “false”% >

The solution to the problem that the El expression in the above JSP page is treated as a string and does not display a value is all the content that Xiaobian shared with you. I hope to give you a reference, and I hope you can support developer more.

Recommended Today

Hot! Front and rear learning routes of GitHub target 144K

Hello, Sifu’s little friend. I’m silent Wang Er. Last week, while appreciating teacher Ruan Yifeng’s science and technology weekly, I found a powerful learning route, which has been marked with 144K on GitHub. It’s very popular. It covers not only the front-end and back-end learning routes, but also the operation and maintenance learning routes. As […]