且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Servlet 2.4容器上运行JSF 2.0

更新时间:2023-12-03 13:46:10

JSF 2.0在很大程度上取决于 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上运行.我在Tomcat 5.5.33上使用/WEB-INF/lib中的以下库在此处进行了快速测试:

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

还有一个声明了JBoss EL的Servlet 2.4 web.xml:

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!),一个简单的<h:form>,一个带有<f:ajax>的按钮和一个简单的@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.