Using EL 2.2 with Tomcat 6.0.24

前端 未结 4 2008
慢半拍i
慢半拍i 2020-12-05 03:13

With JSF 2 you should be able to do this:


which would then call the act

相关标签:
4条回答
  • 2020-12-05 03:46

    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.

    0 讨论(0)
  • 2020-12-05 04:00

    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>
    
    0 讨论(0)
  • 2020-12-05 04:03

    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>
    
    0 讨论(0)
  • 2020-12-05 04:03

    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)

    0 讨论(0)
提交回复
热议问题