English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
I encountered the phenomenon that the EL expression was treated as a string and not parsed correctly during practice. At that time, the Javaee used in the project was5,
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" >
EL expressions could not be parsed and were treated as strings.
Later, I changed web.xml to
<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">
After redeploying and starting tomcat, the EL expression was correctly parsed out.
Later, after further research, I learned that:
This is Jsp2.0's new feature:
II) Introduction of Expression Language (EL)
JSP 2.0's main feature is that it supports expression language (expression language). The JSTL expression language can be used to conveniently access JSP's implicit objects and JavaBeans components, and the core tags of JSTL provide flow and loop control functions. Custom tags also have the function of custom functions, so basically all the functions that can be realized by scriptlets can be replaced by JSP. In JSP 2.0, it is recommended to use EL as much as possible to make the format of JSP more consistent.
In web.xml's <jsp-property-group> can control whether a group of JSP uses EL, and whether each JSP uses EL can also be specified. The isELIgnored attribute in the page directive is used to specify whether to ignore. The format is:
<%@ page isELIgnored="true|false"%>
If set to true, the expressions in JSP are treated as strings. For example, the following expression <p>${2000 % 20}<//p>When isELIgnored is "true", the output is ${2000 % 20}, and when isELIgnored is "false", the output is100. The default isELIgnored in the Web container is "false".
Although JSP 2.0 allows JSP to use expression language completely and avoid scriptlet, and in actual programming, appropriate methods should be chosen according to the functional requirements of the program and the personal conditions of the programmer. Using expression language in JSP is more convenient and tidy, but since the tags need to be converted, it will be slower when called for the first time; some programmers are more accustomed to JSP 1.2therefore, appropriate programming methods should be selected according to the local conditions in use.
That is to say, in the programming methods before javaee4the default setting is <%@ page isELIgnored="false"%>, while javaee5the default setting may be <%@ page isELIgnored="true"%>.Therefore, in javaee5We can specify the normal parsing of EL expressions by setting <%@ page isELIgnored="false"%> in the JSP page. .
This is the complete solution that the editor shares with everyone for the problem that the EL expression in the above JSP page is treated as a string and the value is not displayed. I hope it can be a reference for everyone, and I also hope everyone will support the Yelling Tutorial.