【问题标题】:Spring and Thymeleaf get 'template mode "HTML" has not been configured.' when jar moved to LinuxSpring 和 Thymeleaf 得到'模板模式“HTML”尚未配置。'当 jar 移至 Linux 时
【发布时间】:2018-12-28 04:29:37
【问题描述】:

我在 Windows 7 上使用 Intellij 开发了一个网站,它可以正常工作。 Thymeleaf 是模板系统。然后我使用 Build artifact 创建一个 jar 文件并将 jar 移动到 Linux 服务器。当我尝试访问网页时,我收到消息“模板模式“HTML”尚未配置”。

spring.thymeleaf.mode=HTML 

在 application.properties 中设置

在 pom 中

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <kotlin.version>1.1.4-2</kotlin.version>
    <thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
    <thymeleaf-layout-dialect.version>2.3.0</thymeleaf-layout-dialect.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.thymeleaf</groupId>
        <artifactId>thymeleaf-spring4</artifactId>
        <version>3.0.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>nz.net.ultraq.thymeleaf</groupId>
        <artifactId>thymeleaf-layout-dialect</artifactId>
        <version>2.3.0</version>
    </dependency>

有些东西在 Intellij 端是隐含的,但在 Linux 端却没有,但我看不出是什么。

【问题讨论】:

    标签: spring-boot thymeleaf


    【解决方案1】:

    删除spring.thymeleaf.mode=HTML

    Spring boot 会使用默认模式HTML5

    【讨论】:

    • HTML5 需要 XHTML 格式而不是 HTML。前端人员希望使用与他们的工具兼容的 HTML。
    猜你喜欢
    • 1970-01-01
    • 2017-06-21
    • 1970-01-01
    • 1970-01-01
    • 2018-02-18
    • 2019-10-31
    • 1970-01-01
    • 2016-01-26
    • 1970-01-01
    相关资源
    最近更新 更多