The el expression in the jsp file in maven project is invalid.

Source: Internet
Author: User

The el expression in the jsp file in maven project is invalid.

It was originally intended to write a small demo of springmvc. After the prototype was set up, it was ready to be used as a maven project, and the maven project was re-built. It started from here...

Maven uses web 2.3 by default to create a web project. the xml file header is also Version 2.3 .. to be honest, I didn't use maven to create a project before. Later I thought maven projects were too convenient to look at the source code, so I didn't care about it here .. the introduced version of javax-servlet-api 2.5. then we found that the el expressions in the jsp file are output as they are, and it seems that the el expressions are not parsed at all .. this is strange. Fortunately, there was an identical demo created by non-maven before, and there was no problem after running it again .. basically, the maven issue is locked, and the root cause of differentiation is also determined on the web 2.3 version ..

Then Baidu, basically the answer is: Before 2.5, web. in the header definition in the xml file, el expressions are ignored by default and are not parsed. Therefore, the expression declared for parsing el needs to be displayed. There are three solutions:

Solution 1: Add the following content to the jsp file header:

<%@ page isELIgnored="false" %>

Solution 2 is defined in the web. xml file as follows:

<jsp-config>    <jsp-property-group>        <url-pattern>*.jsp</url-pattern>        <el-ignored>false</el-ignored>        <scripting-invalid>true</scripting-invalid>    </jsp-property-group></jsp-config>

Solution 3: Change the header in web. xml to version above 2.5 ..

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

These three solutions are indeed effective. I changed the header of web. xml to version 3.0 and ran OK again...

Related Article

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.