已部署 WAR 在 apache tomcat 7 上显示 404

Deployed WAR showing 404 on apache tomcat 7

我正在开发一个 JSF 2.2 应用程序,它已经部署到我的本地 apache tomcat 7 .

tomcat 日志显示部署一切正常,但我在指向路径后收到 404。

在 apache 网络管理员上显示应用 运行。

我是从零开始创建项目,没有任何 ide ,文件结构是标准的 maven webapp 结构。

 ago 10, 2017 1:24:06 PM org.apache.catalina.startup.HostConfig undeploy
INFORMACIËN: Repliegue (undeploy) de la aplicaci¾n web que tiene como trayectori
a de contexto /hello1-1.0
ago 10, 2017 1:24:06 PM org.apache.catalina.startup.HostConfig deployWAR
INFORMACIËN: Despliegue del archivo C:\Apache\apache-tomcat-7.0.68-windows-x64\a
pache-tomcat-7.0.68\webapps\hello1-1.0.war de la aplicaci¾n web
ago 10, 2017 1:24:06 PM org.apache.catalina.startup.TldConfig execute
INFORMACIËN: At least one JAR was scanned for TLDs yet contained no TLDs. Enable
 debug logging for this logger for a complete list of JARs that were scanned but
 no TLDs were found in them. Skipping unneeded JARs during scanning can improve
startup time and JSP compilation time.
ago 10, 2017 1:24:06 PM org.apache.catalina.startup.HostConfig deployWAR
INFORMACIËN: Deployment of web application archive C:\Apache\apache-tomcat-7.0.6
8-windows-x64\apache-tomcat-7.0.68\webapps\hello1-1.0.war has finished in 297 ms

这是我的 pom.xml

<project>
<groupId>com.lol</groupId>
<artifactId>hello1</artifactId>
<version>1.0</version>
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<dependencies>
    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
        <version>2.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.faces</groupId>
        <artifactId>javax.faces-api</artifactId>
        <version>2.2</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.8.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.8.2</version>
    </dependency>
</dependencies>
<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
    <filters>
        <filter>src/env/${env}.properties</filter>
    </filters>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
    <testResources>
        <testResource>
            <directory>src/test/resources</directory>
            <filtering>true</filtering>
        </testResource>
    </testResources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <webXml>src/webapp/WEB-INF/web.xml</webXml>
                <outputDirectory>C:\Apache\apache-tomcat-7.0.68-windows-x64\apache-tomcat-7.0.68\webapps</outputDirectory>
            </configuration>
        </plugin>
    </plugins>
</build>
<profiles>
    <profile>
        <id>dev</id>
        <properties>
            <env>dev</env>
        </properties>
        <activation>
            <activeByDefault>true </activeByDefault>
        </activation>
    </profile>
    <profile>
        <id>qa</id>
        <properties>
            <env>qa</env>
        </properties>
    </profile>
    <profile>
        <id>preprod</id>
        <properties>
            <env>preprod</env>
        </properties>
    </profile>
    <profile>
        <id>prod</id>
        <properties>
            <env>prod</env>
        </properties>
    </profile>
</profiles>

还有我的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>Hello1</display-name>

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

    <!-- Map these files with JSF -->
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>

</web-app>

我的索引

     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
    <title>Facelets Hello Greeting</title>
</h:head>
<h:body>
    <h:form>
        <h:graphicImage url="#{resource['images:duke.waving.gif']}" alt="Duke waving his hand" />
        <h2>Hello, my name is Duke. What's yours?</h2>
        <h:inputText id="username" title="My name is: " value="#{hello.name}" required="true" requiredMessage="Error: A name is required."
            maxlength="25" />
        <p></p>
        <h:commandButton id="submit" value="Submit" action="response">
        </h:commandButton>
        <h:commandButton id="reset" value="Reset" type="reset">
        </h:commandButton>
    </h:form>
</h:body>

</html>

我使用了 glassfish 服务器并更改了 java-ee-api 依赖项的 faces 依赖项,效果非常好。