将 jsf 项目转换为 Facelets 2.0 时出现的问题

发布于 2024-12-11 04:34:01 字数 17763 浏览 0 评论 0原文

我在使用 Facelets 将项目从我认为的 jsf 1.1 或 1.2 转换为 jsf 2.0 时遇到问题。

我已经阅读了很多有关如何执行此操作的问题,但我仍然遇到问题。我遇到的问题是 jsf 标签没有呈现为 html 标签

我是 JSF 的新手,仍在努力掌握它的窍门。

主页:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html   xmlns="http://www.w3.org/1999/xhtml"  
    xmlns:h="http://java.sun.com/jsf/html" 
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:t="http://myfaces.apache.org/tomahawk" 
        xmlns:p="http://primefaces.prime.com.tr/ui"
        xmlns:rich="http://richfaces.org/rich"
        xmlns:j4j="http://javascript4jsf.dev.java.net/">

<h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Language" content="en-us">
    <link type="text/css" rel="stylesheet" href="../theme/style.css" />

    <title>Administration</title>

</h:head>

<h:body>

<div id="home"><ui:include page="../common/includes/page.html" flush="true" /></div>


    <f:loadBundle basename="path/to/messages" var="cca" />
    <div class="title">
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td colspan="2">
            <h1>Administration</h1>
            </td>
        </tr>
    </table>
    </div>
    <h:form style="display: inline;">

        <t:div styleClass="header_section">Main</t:div>

        <div class="left clearL contentBox">
            <ul>
                <li>
                    <h:commandLink id="personnel" action="go_personnel">
                        <h:outputText value="Membership Management" styleClass="portallink" />
                    </h:commandLink>
                </li>

                <li>
                    <h:commandLink id="funding" action="go_fund">
                        <h:outputText value="Funding Source Management" styleClass="portallink" />
                    </h:commandLink>
                </li>

                <li>
                    <h:outputLink value="#">
                        <h:outputText value="Publications and Bibliographies" styleClass="portallink"/>
                    </h:outputLink>
                </li>
            </ul>
        </div>

        <t:div styleClass="header_section">Pages</t:div>

        <div class="left clearL contentBox">

            <ul>
                <li>
                    <h:commandLink id="mbr" action="go_membership">
                        <h:outputText value="Membership" styleClass="portallink"/>
                    </h:commandLink>
                </li>
            </ul>

        </div>

        <t:div styleClass="header_section">Status</t:div>

        <table width="425px">
            <tr>
                <td width="90%">

                </td>       
            </tr>
        </table>

    </h:form>

    <div class="footer">

    <div class="left">
        <p class="left footerText">Contact <a href="#">Systems Management Services</a></p>
        <p class="left clearL">Version 1.8.0</p>
    </div>

    <div class="right">
        <p class="footerText right"><a href="#banner">Top of Page</a></p>
    </div>

</div>
</h:body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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-app_2_5.xsd">


    <context-param>
        <description>
            State saving method: "client" or "server" (= default) See
            JSF Specification 2.5.3
        </description>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>
    <context-param>
        <description>
            Only applicable if state saving method is "server" (=
            default). Defines the amount (default = 20) of the latest
            views are stored in session.
        </description>
        <param-name>
            org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION
        </param-name>
        <param-value>20</param-value>
    </context-param>
    <context-param>
        <description>
            Only applicable if state saving method is "server" (=
            default). If true (default) the state will be serialized to
            a byte stream before it is written to the session. If false
            the state will not be serialized to a byte stream.
        </description>
        <param-name>
            org.apache.myfaces.SERIALIZE_STATE_IN_SESSION
        </param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <description>
            Only applicable if state saving method is "server" (=
            default) and if
            org.apache.myfaces.SERIALIZE_STATE_IN_SESSION is true (=
            default) If true (default) the serialized state will be
            compressed before it is written to the session. If false the
            state will not be compressed.
        </description>
        <param-name>
            org.apache.myfaces.COMPRESS_STATE_IN_SESSION
        </param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <description>
            This parameter tells MyFaces if javascript code should be
            allowed in the rendered HTML output. If javascript is
            allowed, command_link anchors will have javascript code that
            submits the corresponding form. If javascript is not
            allowed, the state saving info and nested parameters will be
            added as url parameters. Default: "true"
        </description>
        <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <description>
            If true, rendered HTML code will be formatted, so that it is
            "human readable". i.e. additional line separators and
            whitespace will be written, that do not influence the HTML
            code. Default: "true"
        </description>
        <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <description>
            If true, a javascript function will be rendered that is able
            to restore the former vertical scroll on every request.
            Convenient feature if you have pages with long lists and you
            do not want the browser page to always jump to the top if
            you trigger a link or button action that stays on the same
            page. Default: "false"
        </description>
        <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
        <param-value>true</param-value>
    </context-param>

    <context-param>
        <description>
            Used for encrypting view state. Only relevant for client
            side state saving. See MyFaces wiki/web site documentation
            for instructions on how to configure an application for
            diffenent encryption strengths.
        </description>
        <param-name>org.apache.myfaces.SECRET</param-name>
        <param-value>NzY1NDMyMTA=</param-value>
    </context-param>

    <context-param>
        <description>
            Validate managed beans, navigation rules and ensure that
            forms are not nested.
        </description>
        <param-name>org.apache.myfaces.VALIDATE</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <description>
            A class implementing the
            org.apache.myfaces.shared.renderkit.html.util.AddResource
            interface. It is responsible to place scripts and css on the
            right position in your HTML document. Default:
            "org.apache.myfaces.shared.renderkit.html.util.DefaultAddResource"
            Follow the description on the MyFaces-Wiki-Performance page
            to enable StreamingAddResource instead of DefaultAddResource
            if you want to gain performance.
        </description>
        <param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
        <param-value>
            org.apache.myfaces.renderkit.html.util.DefaultAddResource
        </param-value>
        <!--param-value>org.apache.myfaces.component.html.util.StreamingAddResource</param-value-->
    </context-param>

    <context-param>
        <description>
            A very common problem in configuring
            MyFaces-web-applications is that the Extensions-Filter is
            not configured at all or improperly configured. This
            parameter will check for a properly configured
            Extensions-Filter if it is needed by the web-app. In most
            cases this check will work just fine, there might be cases
            where an internal forward will bypass the Extensions-Filter
            and the check will not work. If this is the case, you can
            disable the check by setting this parameter to false.
        </description>
        <param-name>
            org.apache.myfaces.CHECK_EXTENSIONS_FILTER
        </param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>org.richfaces.SKIN</param-name>
        <param-value>blueSky</param-value>
    </context-param>
    <context-param>
        <description>
        Comma-delimited list of context-relative resource paths under which the JSF implementation
will look for application configuration resources, before loading a configuration resource
named /WEB-INF/facesconfig.xml (if such a resource exists).</description>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        <param-value>/WEB-INF/faces-config.xml</param-value>
    </context-param>
    <context-param>
        <description>
        The default suffix for extension-mapped resources that contain JSF components.
Default is '.jsp'.</description>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.jsp</param-value>
    </context-param>
    <context-param>
        <description>
        Monitors Faces JSP files for modifications and synchronizes a running server with
the changes without restarting the server. If this parameter is set to false or
removed from the deployment descriptor, any changes made to Faces JSP files may
not be seen by the server until it is restarted. This parameter is usually set
to true while the Faces JSP files are being developed and debugged in order to
improve the performance of the development environment.</description>
        <param-name>com.ibm.ws.jsf.JSP_UPDATE_CHECK</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <description>
        Load JSF runtime when the application server starts up. If this parameter is set to false or removed,
JSF runtime will be loaded and initialized when the first JSF request is processed.
This may disable custom JSF extensions, such as factories defined in the project.</description>
        <param-name>com.ibm.ws.jsf.LOAD_FACES_CONFIG_AT_STARTUP</param-name>
        <param-value>true</param-value>
    </context-param>
    <filter>
        <display-name>RichFaces Filter</display-name>
        <filter-name>richfaces</filter-name>
        <filter-class>org.ajax4jsf.Filter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>richfaces</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>


    <filter>
        <filter-name>extensionsFilter</filter-name>
        <filter-class>
            org.apache.myfaces.webapp.filter.ExtensionsFilter
        </filter-class>
        <init-param>
            <description>
                Set the size limit for uploaded files. Format: 10 - 10
                bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB
            </description>
            <param-name>uploadMaxFileSize</param-name>
            <param-value>100m</param-value>
        </init-param>
        <init-param>
            <description>
                Set the threshold size - files below this limit are
                stored in memory, files above this limit are stored on
                disk.

                Format: 10 - 10 bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB
            </description>
            <param-name>uploadThresholdSize</param-name>
            <param-value>100k</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>extensionsFilter</filter-name>
        <url-pattern>*.jsf</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>extensionsFilter</filter-name>
        <url-pattern>/faces/*</url-pattern>
    </filter-mapping>

    <listener>
     <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
 </listener>

    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <display-name>
        Apache-Axis Servlet</display-name>
        <servlet-name>AxisServlet</servlet-name>
        <servlet-class>
        org.apache.axis.transport.http.AxisServlet</servlet-class>
    </servlet>
    <servlet>
        <display-name>
        Axis Admin Servlet</display-name>
        <servlet-name>AdminServlet</servlet-name>
        <servlet-class>
        org.apache.axis.transport.http.AdminServlet</servlet-class>
        <load-on-startup>100</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>/servlet/AxisServlet</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>*.jws</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>AdminServlet</servlet-name>
        <url-pattern>/servlet/AdminServlet</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>/index.jsp</welcome-file>
        <welcome-file>/index.html</welcome-file>
    </welcome-file-list>

</web-app>

faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>

<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">


    ..managed beans removed..

    ..nav rules removed..

</faces-config>

I'm having an issue with converting a project from what I think is jsf 1.1 or 1.2, to jsf 2.0 using facelets.

I've read many Q's on SO about how to do this and I'm still having issues. The problem i'm having is that the jsf tags are not being rendered as html tags.

I'm newer to JSF and still trying to get the hang of it.

Main Page:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html   xmlns="http://www.w3.org/1999/xhtml"  
    xmlns:h="http://java.sun.com/jsf/html" 
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:t="http://myfaces.apache.org/tomahawk" 
        xmlns:p="http://primefaces.prime.com.tr/ui"
        xmlns:rich="http://richfaces.org/rich"
        xmlns:j4j="http://javascript4jsf.dev.java.net/">

<h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Language" content="en-us">
    <link type="text/css" rel="stylesheet" href="../theme/style.css" />

    <title>Administration</title>

</h:head>

<h:body>

<div id="home"><ui:include page="../common/includes/page.html" flush="true" /></div>


    <f:loadBundle basename="path/to/messages" var="cca" />
    <div class="title">
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td colspan="2">
            <h1>Administration</h1>
            </td>
        </tr>
    </table>
    </div>
    <h:form style="display: inline;">

        <t:div styleClass="header_section">Main</t:div>

        <div class="left clearL contentBox">
            <ul>
                <li>
                    <h:commandLink id="personnel" action="go_personnel">
                        <h:outputText value="Membership Management" styleClass="portallink" />
                    </h:commandLink>
                </li>

                <li>
                    <h:commandLink id="funding" action="go_fund">
                        <h:outputText value="Funding Source Management" styleClass="portallink" />
                    </h:commandLink>
                </li>

                <li>
                    <h:outputLink value="#">
                        <h:outputText value="Publications and Bibliographies" styleClass="portallink"/>
                    </h:outputLink>
                </li>
            </ul>
        </div>

        <t:div styleClass="header_section">Pages</t:div>

        <div class="left clearL contentBox">

            <ul>
                <li>
                    <h:commandLink id="mbr" action="go_membership">
                        <h:outputText value="Membership" styleClass="portallink"/>
                    </h:commandLink>
                </li>
            </ul>

        </div>

        <t:div styleClass="header_section">Status</t:div>

        <table width="425px">
            <tr>
                <td width="90%">

                </td>       
            </tr>
        </table>

    </h:form>

    <div class="footer">

    <div class="left">
        <p class="left footerText">Contact <a href="#">Systems Management Services</a></p>
        <p class="left clearL">Version 1.8.0</p>
    </div>

    <div class="right">
        <p class="footerText right"><a href="#banner">Top of Page</a></p>
    </div>

</div>
</h:body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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-app_2_5.xsd">


    <context-param>
        <description>
            State saving method: "client" or "server" (= default) See
            JSF Specification 2.5.3
        </description>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>
    <context-param>
        <description>
            Only applicable if state saving method is "server" (=
            default). Defines the amount (default = 20) of the latest
            views are stored in session.
        </description>
        <param-name>
            org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION
        </param-name>
        <param-value>20</param-value>
    </context-param>
    <context-param>
        <description>
            Only applicable if state saving method is "server" (=
            default). If true (default) the state will be serialized to
            a byte stream before it is written to the session. If false
            the state will not be serialized to a byte stream.
        </description>
        <param-name>
            org.apache.myfaces.SERIALIZE_STATE_IN_SESSION
        </param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <description>
            Only applicable if state saving method is "server" (=
            default) and if
            org.apache.myfaces.SERIALIZE_STATE_IN_SESSION is true (=
            default) If true (default) the serialized state will be
            compressed before it is written to the session. If false the
            state will not be compressed.
        </description>
        <param-name>
            org.apache.myfaces.COMPRESS_STATE_IN_SESSION
        </param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <description>
            This parameter tells MyFaces if javascript code should be
            allowed in the rendered HTML output. If javascript is
            allowed, command_link anchors will have javascript code that
            submits the corresponding form. If javascript is not
            allowed, the state saving info and nested parameters will be
            added as url parameters. Default: "true"
        </description>
        <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <description>
            If true, rendered HTML code will be formatted, so that it is
            "human readable". i.e. additional line separators and
            whitespace will be written, that do not influence the HTML
            code. Default: "true"
        </description>
        <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <description>
            If true, a javascript function will be rendered that is able
            to restore the former vertical scroll on every request.
            Convenient feature if you have pages with long lists and you
            do not want the browser page to always jump to the top if
            you trigger a link or button action that stays on the same
            page. Default: "false"
        </description>
        <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
        <param-value>true</param-value>
    </context-param>

    <context-param>
        <description>
            Used for encrypting view state. Only relevant for client
            side state saving. See MyFaces wiki/web site documentation
            for instructions on how to configure an application for
            diffenent encryption strengths.
        </description>
        <param-name>org.apache.myfaces.SECRET</param-name>
        <param-value>NzY1NDMyMTA=</param-value>
    </context-param>

    <context-param>
        <description>
            Validate managed beans, navigation rules and ensure that
            forms are not nested.
        </description>
        <param-name>org.apache.myfaces.VALIDATE</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <description>
            A class implementing the
            org.apache.myfaces.shared.renderkit.html.util.AddResource
            interface. It is responsible to place scripts and css on the
            right position in your HTML document. Default:
            "org.apache.myfaces.shared.renderkit.html.util.DefaultAddResource"
            Follow the description on the MyFaces-Wiki-Performance page
            to enable StreamingAddResource instead of DefaultAddResource
            if you want to gain performance.
        </description>
        <param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
        <param-value>
            org.apache.myfaces.renderkit.html.util.DefaultAddResource
        </param-value>
        <!--param-value>org.apache.myfaces.component.html.util.StreamingAddResource</param-value-->
    </context-param>

    <context-param>
        <description>
            A very common problem in configuring
            MyFaces-web-applications is that the Extensions-Filter is
            not configured at all or improperly configured. This
            parameter will check for a properly configured
            Extensions-Filter if it is needed by the web-app. In most
            cases this check will work just fine, there might be cases
            where an internal forward will bypass the Extensions-Filter
            and the check will not work. If this is the case, you can
            disable the check by setting this parameter to false.
        </description>
        <param-name>
            org.apache.myfaces.CHECK_EXTENSIONS_FILTER
        </param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>org.richfaces.SKIN</param-name>
        <param-value>blueSky</param-value>
    </context-param>
    <context-param>
        <description>
        Comma-delimited list of context-relative resource paths under which the JSF implementation
will look for application configuration resources, before loading a configuration resource
named /WEB-INF/facesconfig.xml (if such a resource exists).</description>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        <param-value>/WEB-INF/faces-config.xml</param-value>
    </context-param>
    <context-param>
        <description>
        The default suffix for extension-mapped resources that contain JSF components.
Default is '.jsp'.</description>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.jsp</param-value>
    </context-param>
    <context-param>
        <description>
        Monitors Faces JSP files for modifications and synchronizes a running server with
the changes without restarting the server. If this parameter is set to false or
removed from the deployment descriptor, any changes made to Faces JSP files may
not be seen by the server until it is restarted. This parameter is usually set
to true while the Faces JSP files are being developed and debugged in order to
improve the performance of the development environment.</description>
        <param-name>com.ibm.ws.jsf.JSP_UPDATE_CHECK</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <description>
        Load JSF runtime when the application server starts up. If this parameter is set to false or removed,
JSF runtime will be loaded and initialized when the first JSF request is processed.
This may disable custom JSF extensions, such as factories defined in the project.</description>
        <param-name>com.ibm.ws.jsf.LOAD_FACES_CONFIG_AT_STARTUP</param-name>
        <param-value>true</param-value>
    </context-param>
    <filter>
        <display-name>RichFaces Filter</display-name>
        <filter-name>richfaces</filter-name>
        <filter-class>org.ajax4jsf.Filter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>richfaces</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>


    <filter>
        <filter-name>extensionsFilter</filter-name>
        <filter-class>
            org.apache.myfaces.webapp.filter.ExtensionsFilter
        </filter-class>
        <init-param>
            <description>
                Set the size limit for uploaded files. Format: 10 - 10
                bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB
            </description>
            <param-name>uploadMaxFileSize</param-name>
            <param-value>100m</param-value>
        </init-param>
        <init-param>
            <description>
                Set the threshold size - files below this limit are
                stored in memory, files above this limit are stored on
                disk.

                Format: 10 - 10 bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB
            </description>
            <param-name>uploadThresholdSize</param-name>
            <param-value>100k</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>extensionsFilter</filter-name>
        <url-pattern>*.jsf</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>extensionsFilter</filter-name>
        <url-pattern>/faces/*</url-pattern>
    </filter-mapping>

    <listener>
     <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
 </listener>

    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <display-name>
        Apache-Axis Servlet</display-name>
        <servlet-name>AxisServlet</servlet-name>
        <servlet-class>
        org.apache.axis.transport.http.AxisServlet</servlet-class>
    </servlet>
    <servlet>
        <display-name>
        Axis Admin Servlet</display-name>
        <servlet-name>AdminServlet</servlet-name>
        <servlet-class>
        org.apache.axis.transport.http.AdminServlet</servlet-class>
        <load-on-startup>100</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>/servlet/AxisServlet</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>*.jws</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>AdminServlet</servlet-name>
        <url-pattern>/servlet/AdminServlet</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>/index.jsp</welcome-file>
        <welcome-file>/index.html</welcome-file>
    </welcome-file-list>

</web-app>

faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>

<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">


    ..managed beans removed..

    ..nav rules removed..

</faces-config>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不必了 2024-12-18 04:34:01

那么,您想在 Facelets 上使用 JSF 2.0 吗?我猜您还希望能够继续使用旧的 JSP 文件?

混合使用 JSF 1.x 和 JSF 2.x 声明,很难通过问题中的 web.xml 怪物进行爬行。关键点是删除 javax.faces.DEFAULT_SUFFIX (您错误地将其设置为 .jsp)并更改 FacesServlet 映射在 *.xhtml 上。

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

此外,您的 ExtensionsFilter 可以更好地映射到 FacesServlet 的单个 servlet 映射上。

<filter-mapping>
    <filter-name>extensionsFilter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

这样 Facelets 文件就必须正常工作。当 foo.xhtml 不存在,但 foo.jsp 确实存在时,它将在 *.xhtml URL 模式后面提供服务。

另请参阅:

So, you want to use JSF 2.0 on Facelets? I gather that you also want to be able to still use the old JSP files?

It's hard crawling through that web.xml monster in your question with a mix of JSF 1.x and JSF 2.x declarations. The key points are the removal of the javax.faces.DEFAULT_SUFFIX (which you've incorrectly set to .jsp) and changing the FacesServlet mapping on *.xhtml.

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

Also, your ExtensionsFilter can better be mapped on a single servlet mapping of FacesServlet.

<filter-mapping>
    <filter-name>extensionsFilter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

This way the Facelets files must work properly. When a foo.xhtml does not exist, but a foo.jsp does exist, then it will be served instead behind *.xhtml URL pattern.

See also:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文