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表达式:

[xhtml] view plaincopyprint?

  1. <web-app version="2.5"  
  2. xmlns="http://java.sun.com/xml/ns/javaee"  
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  
  5. http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">  

解决方法:
1.修改web.xml文件为(Servlet 2.4 / JSP 2.0):

[xhtml] view plaincopyprint?

  1. <web-app version="2.4"  
  2. xmlns="http://java.sun.com/xml/ns/javaee"  
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  
  5. http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd">  

2.设置某个jsp页面使用el表达式,需要在jsp页面加上(控制单个页面) :

[xhtml] view plaincopyprint?

  1. <%@ page isELIgnored="false"%>  

或在web.xml文件中加上下列代码,这样就不用在每个jsp页面中指定了。

[xhtml] view plaincopyprint?

  1. <jsp-config>  
  2.   <jsp-property-group>  
  3.     <url-pattern>*.jsp</url-pattern>  
  4.     <el-ignored>false</el-ignored>  
  5.   </jsp-property-group>  
  6. </jsp-config>  

附:网上提供的更详细的设置(有点啰嗦,但是可以用来参考)

[xhtml] view plaincopyprint?

  1. <jsp-config>  
  2.         <jsp-property-group>  
  3.             <description>指定JSP文件的配置属性</description>  
  4.             <display-name>jspConfiguration</display-name>  
  5.             <url-pattern>*.jsp</url-pattern>  
  6.             <el-ignored>false</el-ignored>  
  7.             <page-encoding>utf-8</page-encoding>  
  8.             <scripting-invalid>false</scripting-invalid>  
  9.             <include-prelude></include-prelude>  
  10.             <include-coda></include-coda>  
  11.         </jsp-property-group>  
  12.         <jsp-property-group>  
  13.             <description>指定htm文件的配置属性</description>  
  14.             <display-name>jspConfiguration</display-name>  
  15.             <url-pattern>*.htm</url-pattern>  
  16.             <el-ignored>false</el-ignored>  
  17.             <page-encoding>utf-8</page-encoding>  
  18.             <scripting-invalid>false</scripting-invalid>  
  19.             <include-prelude></include-prelude>  
  20.             <include-coda></include-coda>  
  21.         </jsp-property-group>  
  22.         <jsp-property-group>  
  23.             <description>指定html文件的配置属性</description>  
  24.             <display-name>jspConfiguration</display-name>  
  25.             <url-pattern>*.html</url-pattern>  
  26.             <el-ignored>false</el-ignored>  
  27.             <page-encoding>utf-8</page-encoding>  
  28.             <scripting-invalid>false</scripting-invalid>  
  29.             <include-prelude></include-prelude>  
  30.             <include-coda></include-coda>  
  31.         </jsp-property-group>  
  32.     </jsp-config>  
没有登录不能评论