首页 > 解决方案 > Wildfly 没有看到 .xhtml 扩展名

问题描述

我正在使用 jdk 11 和 wildfly 18。创建动态 Web 项目后,我将其转换为 maven 项目。然后我在 pom.xml 的下面添加,我正在处理这个项目,然后我没有找到 404。WebContent 有一个 NewFile.xhtml。然后我在 wildfly 中运行该项目,但它不起作用。实际上,我的项目在转换为 maven 项目之前正在运行。转换后,项目不起作用。Url 扩展名:http://localhost:8080/JSFWeek02/welcome.xhtml。在我运行项目后自动 url 扩展是:http://localhost:8080/JSFWeek02/faces/welcome.xhtml。我不知道为什么我会出错。如果你能帮助我,我会很高兴的。

web.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>JSFWeek01</groupId>
    <artifactId>JSFWeek01</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.3</version>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>


    <dependencies>
        <!-- https://mvnrepository.com/artifact/com.sun.faces/jsf-impl -->
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.20</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.sun.faces/jsf-api -->
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.20</version>
        </dependency>

    </dependencies>

</project>

新文件.xhtml

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Shen</title>
</head>
<body>
    
    I am <h:outputText value="Kerem"/>
    
</body>
</html>

标签: mavenjsfwildfly

解决方案


推荐阅读