从JSF 1.2迁移到JSF 2.0

时间:2010-12-14 16:44:37

标签: java jsf migration jsf-2

我正在使用 JSF 1.2 编写的相当大的应用程序。 JSF 1.2现在已经有6年了。我需要升级到JSF 2.0。这会有多痛苦?我注意到自定义标签中的某些属性已更改等。

5 个答案:

答案 0 :(得分:239)

答案 1 :(得分:7)

有一点要提到的是,如果有人使用JSTL和JSF 1.2,那么当升级到JSF2时,你应该改变命名空间:

http://java.sun.com/jstl/core

为:

http://java.sun.com/jsp/jstl/core

答案 2 :(得分:6)

JSF 2.0有许多新功能和组件,我觉得迁移不会很痛苦。只有你会发现困难的地方是使用第三方图书馆。如果您的应用程序严重依赖于像Richfaces这样的库,那么您将面临问题。并非Richfaces 3中的所有组件都移植到Richfaces 4。

这也可能有所帮助 JSF 1.2 application migration to JSF 2.0

同时检查此What is new in JSF 2?

答案 3 :(得分:4)

Web.xml中

 Add the jars
    1. jsf-api-2.0.jar 
    2. jsf-impl.2.0.2.jar

第1步:更改web.xml

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
            xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
            id="WebApp_ID" version="2.5">


    <servlet>
            <servlet-name>facesServlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>

        <servlet-mapping>
            <servlet-name>facesServlet</servlet-name>
            <url-pattern>/faces/*</url-pattern>
        </servlet-mapping>
        <servlet-mapping>

            <servlet-name>facesServlet</servlet-name>
            <url-pattern>*.jsf</url-pattern>
        </servlet-mapping>

        <servlet-mapping>
            <servlet-name>facesServlet</servlet-name>
            <url-pattern>*.faces</url-pattern>
        </servlet-mapping>

        <servlet-mapping>
            <servlet-name>facesServlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
        </servlet-mapping>

第2步:webmvc-config.xml

<!-- Handles requests mapped to the Spring Web Flow system -->
    <bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController">
        <property name="flowExecutor" ref="flowExecutor" />
        <property name="ajaxHandler">
            <bean class="org.springframework.faces.webflow.JsfAjaxHandler" />
        </property>
</bean>

步骤3:facess-config.xml中

<faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0">

答案 4 :(得分:0)

如果您使用的是Apache Trinidad,您还必须将其升级到2.0版,以便它支持JSF 2.0。 Hacker's Valhalla上有更多信息。

相关问题