Spring boot JSF标记(xHTML)不会在浏览器上呈现为HTML

Spring boot JSF标记(xHTML)不会在浏览器上呈现为HTML,spring-boot,jsf,primefaces,Spring Boot,Jsf,Primefaces,我正在尝试用spring boot做JSF Primefaces HTML页面工作正常 但是xHTML页面不会呈现为HTML。如果我在浏览器上执行F12,我会看到JSF标记 我已看过: 我看到URL与FacesServlet映射匹配:请看下面的my Web.xml XML名称空间是用于JSF2.2的:请看下面的my Web.XML和网页 我不太确定最后一个: “已加载多个JSF实现” 在我的库中,我看到了“Maven:org.glassfish.jaxb:txw2:2.3.3”和“Mave

我正在尝试用spring boot做JSF Primefaces HTML页面工作正常

但是xHTML页面不会呈现为HTML。如果我在浏览器上执行F12,我会看到JSF标记

我已看过:

  • 我看到URL与FacesServlet映射匹配:请看下面的my Web.xml
  • XML名称空间是用于JSF2.2的:请看下面的my Web.XML和网页
我不太确定最后一个:

“已加载多个JSF实现”

在我的库中,我看到了“Maven:org.glassfish.jaxb:txw2:2.3.3”和“Maven:org.glassfish:jakarta.el:3.0.3”以及tomcat。我也没有添加,也无法从IntelliJ IDE的项目结构中删除它们: 这是我的pom文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>caom.test</groupId>
    <artifactId>motive</artifactId>
    <version>0.0.1</version>
    <name>TestApp</name>
    <description>Motive WebApp for Propositom project</description>

    <properties>
        <java.version>14</java.version>
        <servlet.version>3.1.0</servlet.version>
        <jsf.version>2.2.8</jsf.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>${servlet.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>${jsf.version}</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>${jsf.version}</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.4.18.Final</version>
        </dependency>

        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>8.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>2.4.0-M1</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.4.18.Final</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

4.0.0
org.springframework.boot
spring启动程序父级
2.3.1.1发布
caom试验
动机
0.0.1
特斯塔普
Propositom项目的动机WebApp
14
3.1.0
2.2.8
org.springframework.boot
SpringBootStarterWeb
org.postgresql
postgresql
运行时
org.springframework.boot
弹簧起动试验
测试
org.junit.vintage
朱尼特老式发动机
javax.servlet
javax.servlet-api
${servlet.version}
假如
com.sun.faces
JSFAPI
${jsf.version}
com.sun.faces
jsf impl
${jsf.version}
org.hibernate
冬眠核心
5.4.18.最终版本
org.primefaces
素面
8
org.springframework.data
spring数据jpa
2.4.0-M1
org.hibernate
冬眠核心
5.4.18.最终版本
org.springframework.boot
springbootmaven插件
这是我的Web.xML

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="4.0"
         xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                             http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd">

    <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>
    <welcome-file-list>
        <welcome-file>/WebPage/Welcome.xhtml</welcome-file>
    </welcome-file-list>

</web-app>

Facesservlet
javax.faces.webapp.FacesServlet
1.
Facesservlet
*.xhtml
/网页/Welcome.xhtml
faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns="http://xmlns.jcp.org/xml/ns/javaee"
              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                                  http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd" version="2.2">

</faces-config>

这是我的网页

<!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://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">

<ui:composition template="/templates/WebPageTemplate.xhtml">
    <ui:param name="pageTitle" value="Home"/>
    <ui:define name="Header">
        <title> home | Motive</title>
    </ui:define>
    <ui:define name="MainBody">
        <h3><strong>This is HTML</strong></h3>
        <p>And it is sowing</p>
        <h:outputText value="This is JSF, and it is not sowing"/>
    </ui:define>
</ui:composition>
</html>

家|动机
这是HTML
它正在播种

我甚至重新创建了这个项目,以防出现一些隐藏的配置错误


如果您不知道答案,但可以为我提供一个关于如何设置此设置,甚至如何跟踪渲染的好教程。那太好了

将此添加到模板中

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">

并将其添加到您的webpage.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                template="/templates/WebPageTemplate.xhtml">

同时尝试更改路径template=“/WEB-INF/templates/WebGetTemplate.xhtml


我不知道这是否能解决您的问题,它可能是由许多因素造成的。

因此我最终删除了WEB-INF并使用了JoinFaces 4.3 下面是一个类似github的示例代码:


检查项目是否提供了JSF与Spring Boot的集成您使用的是什么应用服务器?如果我正确理解了您的问题,我没有指定一个,所以我认为应该是tomcat。这是一个包装罐,而不是一场战争