The el expression does not take effect in the maven-web project

Problem Description

When El expressions are used in jsp pages, the page directly outputs the following format:
insert image description here
Reason analysis:
Servlet2.3 does not support EL expressions by default, check the version of web-app_2_3.dtd, before 2.3, the default isELIgnored attribute is true, that is, < xsd:attribute name="isELIgnored" default="true" type="Bool"/>.
Only Servlet2.4 and above versions support EL expressions.

Solution:

  • The first method: add the instruction <%@ page isELIgnored="false" %> to the page that needs to use the el expression
  • The second method: replace all the contents of the web.xml configuration file with:
<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">

</web-app>

Guess you like

Origin blog.csdn.net/weixin_48627356/article/details/122526369