【问题标题】:thymeleaf sitemesh integrate , decorate.html not parsethymeleaf sitemesh 集成,decorate.html 不解析
【发布时间】:2014-11-08 18:22:09
【问题描述】:

在 /WEB-INF/decorate/decorate.html 中,我想使用一些 thymeleaf 标签库,例如“th:text”。

 <html>
 <head>
        <title><sitemesh:write property='title'/></title>
        <sitemesh:write property='head'/>
 </head>
 <body>
      <p th:text="${message}">message</p>
      <sitemesh:write property='body'/>
 </body>
 </html>

你好.html

 <html>
 <head>
        <title>test</title>
 </head>
 <body>
        Hello world     
 </body>
 </html>

返回结果是

 <html>
 <head>
        <title>test</title>
 </head>
 <body>
      <p th:text="${message}">message</p>
      Hello world     
 </body>
 </html>

thymeleaf 没有解析“消息”。是bug吗?

【问题讨论】:

    标签: thymeleaf sitemesh


    【解决方案1】:

    假设您正确配置了模板解析器和模板引擎。在您共享的 HTML 中,您尚未定义 th 标准方言定义。

    <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:th="http://www.thymeleaf.org">
    <head>
            <title><sitemesh:write property='title'/></title>
            <sitemesh:write property='head'/>
     </head>
     <body>
          <p th:text="${message}">message</p>
          <sitemesh:write property='body'/>
     </body>
     </html>
    

    【讨论】:

    • 我的配置是正确的。因为如果我将

      message

      放在 hello.html 中,“消息”将被正确解析。这个 xmlns 只是用来识别标签吗?
    • 如果是这种情况,您可以查看正在寻找 .jsp 而不是 .html 的解析器
    猜你喜欢
    • 2017-02-25
    • 1970-01-01
    • 2021-10-10
    • 1970-01-01
    • 1970-01-01
    • 2020-03-14
    • 2013-06-20
    • 1970-01-01
    • 2017-07-25
    相关资源
    最近更新 更多