EL表达式无效?

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/y694721975/article/details/53454210

好久没用过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>

猜你喜欢

转载自blog.csdn.net/y694721975/article/details/53454210
今日推荐