简体   繁体   English

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

[英]404 /index.xhtml Not Found in ExternalContext as a Resource

I am aware that there are similar questions related to this topic. 我知道有与此主题相关的类似问题。 However, none of the answers did help me and I simply can't get my Intellij/Tomcat running correctly. 但是,没有任何答案对我有帮助,我也无法正常运行Intellij / Tomcat。

Tomcat is not able to find any *.xhtml or plain html file. Tomcat无法找到任何* .xhtml或纯html文件。 Every single time I try to run the project out of IntellIj I just get the error mentioned in the title. 每当我尝试从IntellIj中运行项目时,我都会得到标题中提到的错误。 I also tried deploying the project with maven. 我还尝试使用Maven部署项目。 Didn't work out well (same problem). 效果不好(相同的问题)。

I installed Tomcat with Xampp in the default location C:\\xampp on a Win10 64 bit machine. 我在X10的Win10 64位计算机上的默认位置C:\\ xampp中安装了Tomcat和Xampp。 Here is how my project is structured: 这是我的项目的结构:

在此处输入图片说明

I defined all my dependencies in the pom.xml plus the plugin to deploy the web app on tomcat: 我在pom.xml和插件中定义了我的所有依赖关系,以便在tomcat上部署Web应用程序:

   <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>${servlet.version}</version>
      <scope>provided</scope>
    </dependency>
    <!-- Mojarra JSF -->
    <dependency>
      <groupId>com.sun.faces</groupId>
      <artifactId>jsf-api</artifactId>
      <version>${mojarra.version}</version>
    </dependency>
    <dependency>
      <groupId>com.sun.faces</groupId>
      <artifactId>jsf-impl</artifactId>
      <version>${mojarra.version}</version>
    </dependency>
    <!-- PrimeFaces -->
    <dependency>
      <groupId>org.primefaces</groupId>
      <artifactId>primefaces</artifactId>
      <version>${primefaces.version}</version>
    </dependency>
    <dependency>
        <groupId>org.primefaces.extensions</groupId>
        <artifactId>all-themes</artifactId>
        <version>1.0.8</version>
    </dependency>

What i configured for Tomcat in Intellij: Run/Debug settings in Intellij 我在Intellij中为Tomcat配置的内容:Intellij中的运行/调试设置

I no longer have any idea whatsoever what this could be. 我不再知道这可能是什么。 Checked URLs multiple times, threw away that declaration for the virtual /faces/* folder in the web.xml. 多次检查URL,将该声明丢弃为web.xml中的虚拟/ faces / *文件夹。 Here's my full web.xml: 这是我完整的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>
    <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>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>

    <listener>
        <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>
    <listener id="ServiceLocator">
        <display-name>InitializeContextListener</display-name>
        <listener-class>wuhu.webclient.InitializeContextListener</listener-class>
    </listener>


    <context-param>
        <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>
    <context-param>
        <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
        <param-value>resources.application</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>WUHU_SERVICE_URL</param-name>
        <param-value>http://localhost:%s/wuhuservice</param-value>
    </context-param>
    <context-param>
        <param-name>WUHU_SERVICE_PORT</param-name>
        <param-value>8123</param-value>
    </context-param>
</web-app>

有问题的Maven项目结构,由JimHawkins在评论中回答

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM