pages / index.xhtml在ExternalContext中找不到作为资源

时间:2015-11-09 19:24:09

标签: java spring jsf jsf-2

我开发了一个简单的项目。我使用JSF + Spring框架。 我的JSF Web应用程序显示以下错误:

HTTP状态404 - 在ExternalContext中找不到/pages/index.xhtml作为资源

我的目录结构:

-src

--main

---webapp

----WEB-INF

-----pages

------index.xhtml

我的web.xml

     <!-- Spring Context Configuration' s Path definition -->
      <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>
      /WEB-INF/config/applicationContext.xml
      </param-value>
   </context-param>
    <!-- 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>

    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>

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

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

谢谢:)

1 个答案:

答案 0 :(得分:2)

将pages文件夹放在webapp文件夹中