0

プロジェクトを .jsp から Facelets に徐々に移行しようとしていますが、控えめに言っても多くの問題を抱えています。

現在の jsf タグは、.jsp ページで適切にレンダリングされています。

シンプルな .xhtml ページ

<!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:rich="http://richfaces.org/rich"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:p="http://primefaces.org/ui"> 

           <h:head>
                <title>This is a Test</title>    
             </h:head> 

           <h:body>
           <div>
                <H2>
                    <h:outputText value="test"/>
                </H2>
                </div>
        </h:body>
</html>

ページに直接アクセスしようとすると (somePage.xhtml) タイトルがレンダリングされますが、JSF タグは解析されません(ページを検査すると、html ではなく JSF コンポーネントが表示されます)。

仮想 URL (somePage.cps) を使用しようとすると、タイトルも JSF タグもレンダリングされません。(ページ閲覧では何も表示されません)

私が読んでいるのは、これは JSF タグが渡されていないためFacesServletです。

私のweb.xmlには

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.cps</url-pattern>
    </servlet-mapping>

私は JSF を初めて使用し、このプロジェクトは私に引き継がれました。.cps の仮想 URL パターンを使用しています。

ここに記載されている修正を試みました

JSF 1.2 から JSF 2.0 への移行

そしてここ

JSF2 プロジェクトで JSP と XHTML (Facelets) を混在させる - 可能ですか?

** ********完全な 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">
    <display-name>Copyright 2012 University of Kentucky</display-name>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        <param-value>/WEB-INF/config/jsf/faces-config.xml</param-value>
    </context-param>
    <context-param>
        <param-name>org.ajax4jsf.DEFAULT</param-name>
        <param-value>classic</param-value>
    </context-param>
    <!-- Define the basename for a resource bundle for I18N -->
    <context-param>
        <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
        <param-value>messages</param-value>
    </context-param>
    <!-- Plugging the "Blue Sky" skin into the project -->

    <context-param>
        <param-name>org.richfaces.SKIN</param-name>
        <param-value>glassX</param-value>
    </context-param>

    <context-param>
        <param-name>org.apache.myfaces.ERROR_HANDLER</param-name>
        <param-value>edu.uky.cepis.util.global.error.JSFCustomErrorHandler</param-value>
    </context-param>

    <!-- Making the RichFaces skin spread to standard HTML controls -->
    <context-param>
        <param-name>org.richfaces.CONTROL_SKINNING</param-name>
        <param-value>enable</param-value>
    </context-param>

    <!-- 1. Setup two parameters: -->
    <!-- b) Logging configuration file -->
    <!-- b) Spring configuration file -->
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/classes/log4j.properties</param-value>
    </context-param>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/config/spring/cepis-*</param-value>
    </context-param>

    <context-param>
        <param-name>contextFactory</param-name>
        <param-value>
            com.tonbeller.wcf.controller.RequestContextFactoryImpl
        </param-value>
    </context-param>

    <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>*.cps</url-pattern>
    </servlet-mapping>


    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <!-- Defining and mapping the RichFaces filter -->
    <filter>
        <display-name>RichFaces Filter</display-name>
        <filter-name>richfaces</filter-name>
        <filter-class>org.ajax4jsf.Filter</filter-class>
        <init-param>
            <param-name>createTempFiles</param-name>
            <param-value>false</param-value>
        </init-param>
        <init-param>
            <param-name>maxRequestSize</param-name>
            <param-value>100000000</param-value>
        </init-param>
    </filter>
    <!-- Filter for AJAX4JSF <filter> <filter-name>ajax4jsf</filter-name> <filter-class>org.ajax4jsf.Filter</filter-class> 
        </filter> -->
    <filter>
        <filter-name>hibernateViewFilter</filter-name>
        <filter-class>
            org.springframework.orm.hibernate4.support.OpenSessionInViewFilter
        </filter-class>
    </filter>

    <filter>
        <filter-name>struts</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>

    <filter>
        <filter-name>ResponseOverrideFilter</filter-name>
        <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
    </filter>

    <filter>
        <filter-name>JPivotController</filter-name>
        <filter-class>com.tonbeller.wcf.controller.RequestFilter</filter-class>
        <!-- <init-param> <param-name>indexJSP</param-name> <param-value>/index.html</param-value> 
            <description> forward to this page if session is new </description> </init-param> 
            <init-param> <param-name>errorJSP</param-name> <param-value>/error.jsp</param-value> 
            <description>URI of error page</description> </init-param> <init-param> <param-name>busyJSP</param-name> 
            <param-value>/busy.jsp</param-value> <description> This page is displayed 
            if a the user clicks on a query before the previous query has finished </description> 
            </init-param> <init-param> <param-name>forceExtension</param-name> <param-value>.faces</param-value> 
            <description>replace .jsp with .faces</description> </init-param> -->
    </filter>
    <filter>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
        <init-param>
            <param-name>uploadMaxFileSize</param-name>
            <param-value>100m</param-value>
            <!-- <description>Set the size limit for uploaded files.Format: 10 - 10 
                bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB</description> -->
        </init-param>
        <init-param>
            <param-name>uploadThresholdSize</param-name>
            <param-value>100k</param-value>
        </init-param>
    </filter>


    <filter>
        <filter-name>Spring character encoding filter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>


    <!-- Richfaces 3.3.3 Firefox 11 Patch -->
    <filter>
        <filter-name>RichFacesFirefox11Filter</filter-name>
        <filter-class>edu.uky.cepis.filter.patch.RichFacesFirefox11Filter</filter-class>
    </filter>


    <filter-mapping>
        <filter-name>hibernateViewFilter</filter-name>
        <url-pattern>*.cps</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <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-mapping> <filter-name>ajax4jsf</filter-name> <servlet-name>Faces 
        Servlet</servlet-name> </filter-mapping> -->
    <filter-mapping>
        <filter-name>JPivotController</filter-name>
        <url-pattern>/jpivot.action</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>JPivotController</filter-name>
        <url-pattern>/JPivot.jsp</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>ResponseOverrideFilter</filter-name>
        <url-pattern>*.action</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/pages/report/*</url-pattern>
    </filter-mapping>

    <!-- Do not remove this. Needed for proper functioning of struts -->
    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/struts/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>Spring character encoding filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- extension mapping for adding <script/>, <link/>, and other resource 
        tags to JSF-pages -->
    <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <url-pattern>/faces/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>RichFacesFirefox11Filter</filter-name>
        <url-pattern>*.cps</url-pattern>
    </filter-mapping>

    <!-- resources initializer -->
    <listener>
        <listener-class>
            com.tonbeller.tbutils.res.ResourcesFactoryContextListener
        </listener-class>
    </listener>

    <!-- 3. Setup three listeners -->
    <!-- a) Setup a listener to connect spring with the web context -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener> 
        <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class> 
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
    <!-- b) Setup a listener to connect spring with log4J -->
    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>
    <!-- c) Setup ACEGI to subscribe to http session events in the web context 
        <listener> <listener-class>org.acegisecurity.ui.session.HttpSessionEventPublisher</listener-class> 
        </listener> -->
    <listener>
        <listener-class>org.springframework.web.util.WebAppRootListener</listener-class>
    </listener>
    <!-- Spring Security Concurrent Session Listener -->
    <listener>
        <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
    </listener>

    <!-- CAS Authentication -->
    <!-- <servlet> <servlet-name>casproxy</servlet-name> <servlet-class>edu.yale.its.tp.cas.proxy.ProxyTicketReceptor</servlet-class> 
        </servlet> -->
    <!-- Faces Servlet -->


    <!-- Servlet for Report Module -->
    <servlet>
        <servlet-name>JspSupportServlet</servlet-name>
        <servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet>
        <servlet-name>fileServlet</servlet-name>
        <servlet-class>org.efs.openreports.dispatcher.FileDispatcher</servlet-class>
        <load-on-startup>99</load-on-startup>
    </servlet>

    <servlet>
        <servlet-name>MondrianXmlaServlet</servlet-name>
        <servlet-class>org.efs.openreports.dispatcher.XMLADispatcher</servlet-class>
    </servlet>

    <servlet>
        <servlet-name>XFireServlet</servlet-name>
        <servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
    </servlet>

    <!-- jfreechart provided servlet -->
    <servlet>
        <servlet-name>DisplayChart</servlet-name>
        <servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
    </servlet>

    <!-- jfreechart provided servlet -->
    <servlet>
        <servlet-name>GetChart</servlet-name>
        <servlet-class>com.tonbeller.jpivot.chart.GetChart</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>Print</servlet-name>
        <servlet-class>com.tonbeller.jpivot.print.PrintServlet</servlet-class>
    </servlet>

    <!-- EPSB Coldfusion access using Railo -->
    <servlet>
        <servlet-name>CFMLServlet</servlet-name>
        <servlet-class>railo.loader.servlet.CFMLServlet</servlet-class>
        <init-param>
            <param-name>configuration</param-name>
            <param-value>{web-root-directory}/WEB-INF/railo/</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>SpringServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:/org/springframework/batch/admin/web/resources/servlet-config.xml,classpath*:/org/springframework/batch/admin/web/resources/webapp-config.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>




    <!-- CAS Servlet Mapping -->
    <!-- <servlet-mapping> <servlet-name>casproxy</servlet-name> <url-pattern>/casProxy/*</url-pattern> 
        </servlet-mapping> -->
    <!-- Faces Servlet Mapping -->

    <servlet-mapping>
        <servlet-name>DisplayChart</servlet-name>
        <url-pattern>/DisplayChart</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Print</servlet-name>
        <url-pattern>/Print</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>GetChart</servlet-name>
        <url-pattern>/GetChart</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>fileServlet</servlet-name>
        <url-pattern>/report-images/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>fileServlet</servlet-name>
        <url-pattern>/report-files/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>XFireServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>MondrianXmlaServlet</servlet-name>
        <url-pattern>/xmla</url-pattern>
    </servlet-mapping>


    <servlet-mapping>
        <servlet-name>CFMLServlet</servlet-name>
        <url-pattern>*.cfm</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>CFMLServlet</servlet-name>
        <url-pattern>*.cfml</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>CFMLServlet</servlet-name>
        <url-pattern>*.cfc</url-pattern>
    </servlet-mapping>
    <!-- Spring Batch Admin -->
    <servlet-mapping>
        <servlet-name>SpringServlet</servlet-name>
        <url-pattern>/batch/*</url-pattern>
    </servlet-mapping>


    <session-config>
        <session-timeout>15</session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.cps</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>


</web-app>
4

1 に答える 1

0

次のコンテキスト パラメータを削除します (Stephan によって提案された誤った変更を最初に元に戻すことを忘れないでください)。

<context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.jsp</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
    <param-value>*.xhtml</param-value>
</context-param> 

最初のものは基本的に、JSF がデフォルトのビュー テクノロジーとして JSP を使用する必要があることを伝えており、これにより Facelets は認識/使用されません。あなたは確かにそれをしたくありません。2 番目はすでにデフォルトですが、最初のものがそのように設定されている場合は効果がありません。両方を削除するだけです。JSF 2.0 はすでに Facelets (XHTML) にデフォルト設定されています。また、Facelets がデフォルトのビュー テクノロジとして使用されている場合は、JSP が自動的に "フォールバック" として使用されます。JSF 1.2 から JSF 2.0 への移行も参照してください。手順やコード例を見るだけでなく、テキストも注意深く読んでください。

于 2012-09-26T13:18:35.270 に答える