最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - How to resolve thymeleaf fragment(th:replace) is not working with spring boot? - Stack Overflow

programmeradmin1浏览0评论

this is my common file base.html

I created this whole page as a fragment to us on other pages and also want to pass contents to this fragment but it is not working on my about page

base.html

'''
<!DOCTYPE html>
<html lang="en"
th-fragment="parent(content, title)"
xmlns:th=";
>
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <!-- This is the main tailwindcss file output.css -->
   <link rel="stylesheet" data-th-href="@{'/css/output.css'}">

   <!-- flowbite css CDN link for in-built components of tailwindcss -->
   <link href="/[email protected]/dist/flowbite.min.css" 
   rel="stylesheet" />
   <title th-replace="${title}">Document</title>
 </head>
 <body>
    <ul>
    <li>
        <a data-th-href="@{'/home'}">Home</a>
    </li>
    <li>
        <a data-th-href="@{'/about'}">About</a>
    </li>
    <li>
        <a data-th-href="@{'/services'}">Services</a>
    </li>
    <!-- <li>
        <a data-th-href="@{'/home'}">Home</a>
    </li> -->
 </ul>

<section th-insert="${content}"></section>

<!-- flowbite javascript CDN link for in-built components of tailwindcss -->
<script src="/[email protected]/dist/flowbite.min.js"> 
</script>
</body>
</html>
'''

this is the about page which uses the base.html page and pass the arguments

i have added the thymeleaf dependency.

about.html

'''
<!DOCTYPE html>
<html lang="en" 
   xmlns:th=";
   th-replace="~{base::parent(~{::#content}, ~{::title})}">
   <head>
        <title>About</title>
   </head>
   <body>
       <section id="content">
         <h1>Welcome to About Page</h1>
       </section>

       <div th-replace="~{base2::resolved}">Hi , this is about page</div>

   </body>
</html>
'''
发布评论

评论列表(0)

  1. 暂无评论