Servlet2.3默认不支持EL表达式

在jsp页面中使用el表达式,结果el表达式失效,解决办法如下。

方法一:

在jsp页面上添加如下标签

<%@ page isELIgnored="false" %>  

该设置代表在本jsp中使用el表达式,可以解析其中的值。若isELIgnored设置为true,代表在本页不使用el表达式,当做字符串解析出来显示。此时,el表达式正常工作,显示正常。 

方法二:

在web.xml中配置

<jsp-config>  
    <jsp-property-group>  
        <url-pattern>*.jsp</url-pattern>  
        <!-- <el-ignored>默认为true,设置为false即可 -->  
        <el-ignored>false</el-ignored>  
    </jsp-property-group>     
</jsp-config>  

原因:官方解释

If isELIgnored is true, EL expressions are ignored when they appear in static text or tag attributes. If it is false, EL expressions are evaluated 
 
by the container only if the attribute has rtexprvalue set to true or the expression is a deferred expression.
 
The default value of isELIgnored varies depending on the version of the web application deployment descriptor. The default mode for JSP pages 
 
delivered with a Servlet 2.4 descriptor is to evaluate EL expressions; this automatically provides the default that most applications want. The default mode for JSP pages delivered using a descriptor from Servlet 2.3 or before is to ignore EL expressions; this provides backward compatibility.

大概意思也就是说servlet2.3及以前的版本默认是true,不解析el表达式,servlet2.4及更新的版本默认为false,解析el表达式。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值