在 Servlet 2.4 容器上运行 JSF 2.0 [英] Running JSF 2.0 on Servlet 2.4 container

查看:14
本文介绍了在 Servlet 2.4 容器上运行 JSF 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,JSF 2 需要 servlet 2.5,所以它不能在 JBOSS 4.05 (Tomcat 5.5) 上运行.不幸的是,我必须在该环境中部署一个使用 JSF 2.0 和 Primefaces 的应用程序.

As far as I know, JSF 2 requires servlet 2.5, so it doesn't run on JBOSS 4.05 (Tomcat 5.5). Unfortunately I have to deploy an application who uses JSF 2.0 and Primefaces on that environment.

有什么技巧可以使用吗?

Is there any hack to use that?

推荐答案

JSF 2.0 严重依赖于 EL 2.1 它是 Servlet 2.5 的一部分,是与 EL 2.0 是 Servlet 2.4 的一部分,但它不依赖于任何特定的 Servlet 2.5 特定 API.Servlet 2.4 应该也能正常工作.所以理论上,如果您在 /WEB-INF/lib 中提供您自己的 EL 2.1 API 和实现,您可以让 JSF 2.0 在 Servlet 2.4 上工作.我在这里用 /WEB-INF/lib 中的以下库在 Tomcat 5.5.33 上做了一个快速测试:

JSF 2.0 depends heavily on EL 2.1 which is part of Servlet 2.5 and is a major change as opposed to EL 2.0 which is part of Servlet 2.4, but it does not depend on any particular Servlet 2.5 specific API. Servlet 2.4 should work as good. So in theory, you could get JSF 2.0 to work on Servlet 2.4 if you provide your own EL 2.1 API and implementation in /WEB-INF/lib. I did a quick test here on Tomcat 5.5.33 with the following libraries in /WEB-INF/lib:

  • el-api.jar file copied from lib folder of Tomcat 6.0.x
  • jboss-el.jar file (implements EL 2.1 and supports EL 2.2 like method invocation with arguments)
  • jsf-api.jar and jsf-impl.jar from Mojarra 2.0.x

还有一个 Servlet 2.4 web.xml,其中声明了 JBoss EL:

And a Servlet 2.4 web.xml where the JBoss EL is been declared:

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

一个简单的 JSF 2.0 Facelet(不是 JSP!),带有一个简单的 和一个带有 的按钮和一个简单的 @ViewScoped @ManagedBean 在 Tomcat 5.5.33 上对我有用.在 JBoss 4.0.5 上试一试并彻底测试.

A simple JSF 2.0 Facelet (not JSP!) with a simple <h:form> with a button with <f:ajax> and a simple @ViewScoped @ManagedBean works for me on Tomcat 5.5.33. Give it a try on your JBoss 4.0.5 and test it thoroughly.

请注意,您至少需要 JDK 1.5,而不是 JDK 1.4.另请注意,由于存在 Servlet 2.5 特定的 el-api.jar 文件,因此您的应用程序无法移植到任何 Servlet 3.0 容器.

Note that you need a minimum of JDK 1.5, not JDK 1.4. Also note that your application is this way unportable to any Servlet 3.0 container due to presence of the Servlet 2.5 specific el-api.jar file.

这篇关于在 Servlet 2.4 容器上运行 JSF 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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