在 Tomcat 6.0.24 中使用 EL 2.2 [英] Using EL 2.2 with Tomcat 6.0.24

查看:23
本文介绍了在 Tomcat 6.0.24 中使用 EL 2.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 JSF 2,您应该能够做到这一点:

With JSF 2 you should be able to do this:

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

然后调用 action 方法,传入参数(假设它是一个整数):

which would then call the action method, passing in the parameter (assume it's an Integer):

@ManagedBean
@SessionScoped
public class MyBean {
    ...
    public String myAction(Integer myParameter) {
        // do something
        return null;
    }
    ...
}

这在 Glassfish v3 上完美运行.但是不是在 Tomcat 上,您会收到一个 ELException 通知解析错误

This works on Glassfish v3 perfectly. However not on Tomcat, you get an ELException notifying of the parse error

Caused by: javax.el.ELException: Error Parsing: ...

现在,有一个记录的方法可以使用 EL 2.2 和 Glassfish 的实现,通过替换Tomcat lib 目录中的 el-api jar,但是我仍然遇到相同的错误,但没有运气.Tomcat 真的开始让我感到沮丧了!JSF2 意味着更容易!

Now, there's a documented way of making this work using EL 2.2 and Glassfish's implementation by replacing the el-api jar in the Tomcat lib directory, however I still get the same error occurring with no luck. Tomcat's really starting to frustrate me! JSF2 is meant to be easier!

Maven POM 片段:

Maven POM fragments:

<repositories>
  <repository>
    <id>sun</id>
    <url>http://download.java.net/maven/2/</url>
  </repository>
  <repository>
    <id>jboss</id>
    <url>http://repository.jboss.com/maven2/</url>
  </repository>
</repositories>
...
  <dependency>
    <groupId>javax.el</groupId>
    <artifactId>el-api</artifactId>
    <version>2.2</version>
    <scope>provided</scope>
  </dependency>

  <dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>el-impl</artifactId>
    <version>2.2</version>
    <scope>provided</scope>
  </dependency>

<小时>

更多信息.


More info.

这是堆栈跟踪的一部分,似乎它仍在使用 Apache EL 实现,而不是我转储到 lib 中的那个.我完全删除了 Tomcat 附带的现有 el-api.jar,是否有 el-impl.jar 我也打算删除某个可能覆盖某些内容的地方?

Here's part of the stack trace, seems it's still using an Apache EL implementation, and not the one I dumped into lib. I completely removed the existing el-api.jar that came with Tomcat, is there an el-impl.jar I'm meant to remove somewhere too that may be overriding something?

Was expecting one of:
    "}" ...
    "." ...
    "[" ...
    ">" ...
    "gt" ...
    "<" ...
    "lt" ...
    ">=" ...
    "ge" ...
    "<=" ...
    "le" ...
    "==" ...
    "eq" ...
    "!=" ...
    "ne" ...
    "&&" ...
    "and" ...
    "||" ...
    "or" ...
    "*" ...
    "+" ...
    "-" ...
    "/" ...
    "div" ...
    "%" ...
    "mod" ...

    at org.apache.el.parser.ELParser.generateParseException(ELParser.java:2142)
    at org.apache.el.parser.ELParser.jj_consume_token(ELParser.java:2024)
    at org.apache.el.parser.ELParser.DeferredExpression(ELParser.java:113)
    at org.apache.el.parser.ELParser.CompositeExpression(ELParser.java:40)
    at org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:93)
    ... 64 more

推荐答案

正如我在评论中提到的,这可以通过升级 EL 实现来解决(即将 jasper-el.jar 替换为 el-impl-2.2.jar)

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)

这篇关于在 Tomcat 6.0.24 中使用 EL 2.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆