簡體   English   中英

錯誤:在ExternalContext中找不到/JavaServerFaces/default.xhtml作為資源

[英]Error: /JavaServerFaces/default.xhtml Not Found in ExternalContext as a Resource

我從jsf-spring集成開始。 我通過從此鏈接下載jsf-spring整合示例來學習,然后嘗試運行。 當我瀏覽器http://http://localhost:8080/JavaServerFaces/default.xhtml時,發生上述錯誤。 我真的不明白為什么。 我調整為在pom.xml添加jetty插件。 請告訴我。

這是pom.xml添加的部分

<build>
        <finalName>JavaServerFaces</finalName>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12.4</version>
            <configuration>
                <skipTests>true</skipTests>
                <argLine>-Xmx2524m</argLine>
            </configuration>
        </plugin>


        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.3.0.M1</version>
                <configuration>
                    <jvmArgs>-Xmx1048m -Xms536m
                        -XX:PermSize=128m -XX:MaxPermSize=512m</jvmArgs>
                    <reload>manual</reload>
                    <systemProperties>
                        <systemProperty>
                            <name>lib</name>
                            <value>${basedir}/target/spring-mvc/WEB-INF/lib</value>
                        </systemProperty>
                    </systemProperties>
                    <scanIntervalSeconds>3</scanIntervalSeconds>
                    <connectors>
                        <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                            <port>8080</port>
                            <maxIdleTime>60000</maxIdleTime>
                        </connector>
                    </connectors>
                    <contextPath>/</contextPath>
                    <webAppSourceDirectory>${basedir}/src/main/webapp</webAppSourceDirectory>
                    <webXml>${basedir}/src/main/webapp/WEB-INF/web.xml</webXml>
                    <classesDirectory>${basedir}/target/classes</classesDirectory>
                </configuration>
            </plugin>

        </plugins>
    </build>

這里文件web.xml

<?xml version="1.0" encoding="UTF-8"?>
<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">

  <display-name>JavaServerFaces</display-name>

  <!-- Add Support for Spring -->
  <listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>
  <listener>
    <listener-class>
        org.springframework.web.context.request.RequestContextListener
    </listener-class>
  </listener>

  <!-- Change to "Production" when you are ready to deploy -->
  <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
  </context-param>

  <!-- Welcome page -->
  <welcome-file-list>
    <welcome-file>default.xhtml</welcome-file>
  </welcome-file-list>

  <!-- JSF Mapping -->
  <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>*.jsf</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>facesServlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>

</web-app>

我已經解決了我的問題。 我必須瀏覽器http://localhost:8080/default.xhtml而不是http://localhost:8080/JavaServerFaces/default.xhtml 因為在碼頭的插件中,我配置的context path/不是/JavaServerFaces 感謝@BalusC更多:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM