EL的全稱是Expression Language。
1.在默認狀況下,Servlet 2.3 / JSP 1.2是不支持EL表達式的,而Servlet 2.4 / JSP 2.0支持。 servlets 2.4這個版本的isELIgnored默認設置爲false。因此使用web.xml裏用web-app_2_4.xsd聲明的時候在JSP頁面不用特地聲明。
如何查看Servlet / JSP的版本?
打開tomcat的common/lib 目錄下,有兩個JAR文件: jsp-api.jar servlet-api.jar 。若是沒有,那多是你沒有添加進來。解壓這兩個文件,用記事本分別打開META-INF下的MAINMEFT.MF文件。查看Implementation-Version或Specification-Version項。
2.若是web.xml 中web-app 的 version="2.5" ,也不支持EL表達式:
html
<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">
<web-app version="2.4" 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_4.xsd">
<%@ page isELIgnored="false"%>
<jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <el-ignored>false</el-ignored> </jsp-property-group> </jsp-config>
附:網上提供的更詳細的設置(有點囉嗦,可是能夠用來參考)
java
<jsp-config> <jsp-property-group> <description>指定JSP文件的配置屬性</description> <display-name>jspConfiguration</display-name> <url-pattern>*.jsp</url-pattern> <el-ignored>false</el-ignored> <page-encoding>utf-8</page-encoding> <scripting-invalid>false</scripting-invalid> <include-prelude></include-prelude> <include-coda></include-coda> </jsp-property-group> <jsp-property-group> <description>指定htm文件的配置屬性</description> <display-name>jspConfiguration</display-name> <url-pattern>*.htm</url-pattern> <el-ignored>false</el-ignored> <page-encoding>utf-8</page-encoding> <scripting-invalid>false</scripting-invalid> <include-prelude></include-prelude> <include-coda></include-coda> </jsp-property-group> <jsp-property-group> <description>指定html文件的配置屬性</description> <display-name>jspConfiguration</display-name> <url-pattern>*.html</url-pattern> <el-ignored>false</el-ignored> <page-encoding>utf-8</page-encoding> <scripting-invalid>false</scripting-invalid> <include-prelude></include-prelude> <include-coda></include-coda> </jsp-property-group> </jsp-config>