【问题标题】:Thymeleaf th:replace bug?Thymeleaf th:替换错误?
【发布时间】:2018-09-16 16:04:35
【问题描述】:

我有一个包含页脚部分的 layout.html:

<footer th:fragment="site-footer">
&copy; Spring MVC Blog System, 2016
</footer>

我想要它作为我的 index.html 的替代品:

  <div th:replace="layout :: site-footer"></div>

应该很简单,但我还是遇到异常,不知道为什么。

日志:http://pastebin.com/ULDJJciu

【问题讨论】:

  • Exception processing template "index": Exception parsing document: template="layout", line 2 - column 16 (index:12) 你看到了吗,layout.html 的第 2 行 - 第 16 列是什么
  • &lt;html xmlns:th="http://www.thymeleaf.org"&gt; 行粘贴您的模板代码。

标签: html thymeleaf


【解决方案1】:

所以事实证明,它不是关于“th:replace”,它有问题

<html xmlns:th="http://www.thymeleaf.org">

部分,'"' 符号在我的代码中是 UTF8,我应该使用 ASCII。(如果源代码是从网站复制的,则会发生这种情况。)

【讨论】:

  • 你的 IDE 突出显示了吗?
【解决方案2】:

使用 xmlns 作为

<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

对我有用

【讨论】:

    猜你喜欢
    • 2017-01-22
    • 1970-01-01
    • 2019-10-17
    • 2018-04-26
    • 1970-01-01
    • 2015-10-24
    • 2018-05-06
    • 2015-11-19
    • 1970-01-01
    相关资源
    最近更新 更多