EL表达式无效的解决方案

来源:互联网 发布:八一农垦大学淘宝地址 编辑:程序博客网 时间:2024/05/16 11:39

   好久没用过EL表达式了,今天用了竟然不起作用。先说下我的开发环境吧,用的是JDK1.5,Tomcat5.5。最后的解决方案是在JSP页面加<%@ page isELIgnored="false" %> 就OK了。

 

在网上查了一下,问题就出在建Web Project的时候web.xml声明上。
web.xml声明部分一般分为如下版本的xsd,
web-app_2_2.xsd
web-app_2_3.xsd
web-app_2_4.xsd
web-app_2_5.xsd  在默认情况下,Servlet 2.3 / JSP 1.2是不支持EL表达式的,而Servlet 2.4 / JSP 2.0支持

 

下面是官方Documention中isELIgnored Attribute的详解:
The isELIgnored Attribute
• Format
– <%@ page isELIgnored="false" %>
– <%@ page isELIgnored="true" %>
Purpose
– To control whether the JSP 2.0 Expression Language
(EL) is ignored (true) or evaluated normally (false).
• Notes
– If your web.xml specifies servlets 2.3 (corresponding to
JSP 1.2) or earlier, the default is true
• But it is still legal to change the default—you are permitted
to use this attribute in a JSP-2.0-compliant server
regardless of the web.xml version.
– If your web.xml specifies servlets 2.4 (corresponding to
JSP 2.0) or earlier, the default is false

为了不在每个页面添加<%@ page isELIgnored="false" %>,网上说可以在web.xml中这样配置

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

 

但我配了不起作用,还是必须得在页面加了才起作用,不知道是不是跟我用的Tomcat5.5有关?

 

原创粉丝点击