Using EL 2.2 with Tomcat 6.0.24

徘徊边缘 提交于 2019-11-27 19:08:05

As mentioned in other answers, you need to add the el-api-2.2.jar to your Tomcat server's lib folder, and the el-impl-2.2.jar to your WEB-INF/lib folder.

Other answers mention deleting jasper or creating custom implementations of ExpressionFactoryImpl. That might work, but you shouldn't need to do that.

You just need to override the expression factory implementation using org.apache.myfaces.EXPRESSION_FACTORY on MyFaces or com.sun.faces.expressionFactory on Mojarra.

<context-param>
    <param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
  <context-param>
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
  </context-param>

As I mentioned in a comment, this can be solved by upgrading the EL implementation (i.e. replacing jasper-el.jar with el-impl-2.2.jar)

Arend v. Reinersdorff

You can use JBoss EL.

It's an implementation of Expression Language 2.1. But it has extensions to allow method parameters as in your example:

<h:commandButton action="#{myBean.myAction(myParameter)}"/>

The advantage is that you only have to change your webapp and not Tomcat's lib directory.

Instructions

  1. Download the latest version of Seam 2
  2. Extract lib/jboss-el.jar
  3. Copy it to WEB-INF/lib/jboss-el.jar
  4. In your web.xml set:

    <context-param>
        <param-name>com.sun.faces.expressionFactory</param-name>
        <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
    </context-param>
    

See also Invoke direct methods or methods with parameters in EL.

Replacing el-api.jar and el-impl.jar with el-api-2.2.jar and el-impl-2.2.jar solve the problem.

Also you need to add in your context.xml the context parameter

<context-param>
    <param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
  <context-param>
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
  </context-param>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!