Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org.thymeleaf.exceptions.TemplateInputException: Error resolving fragment: template or fragment could not be resolved

I have a weird issue where some of my html files are not being included when I use replace or include. What would cause this?

header.html

 <header id="header" xmlns:th="http://www.thymeleaf.org">
       <div th:replace="/blocks/topbar :: topbar"></div>
 </header>

topbar.html

<div class="top-bar">
    <div class="container">
        <div class="row">
            <div class="col-sm-6 col-xs-4">
                <div class="top-number"><p><i class="fa fa-phone-square"></i>  +0123 456 70 90</p></div>
           </div>
         <div class="col-sm-6 col-xs-8">
            <div class="social">
                <ul class="social-share">
                    <li><a href="#"><i class="fa fa-facebook"></i></a></li>
                </ul>
            </div>
        </div>
      </div>
    </div><!--/.container-->
</div><!--/.top-bar-->

Error:

 org.thymeleaf.exceptions.TemplateInputException: Error resolving fragment: "~{'/blocks/topbar' :: topbar}": template or fragment could not be resolved (template: "blocks/header" - line 3, col 10)
like image 785
Mario Dennis Avatar asked Jan 05 '23 13:01

Mario Dennis


1 Answers

There is no th:fragment="topbar" in your topbar.html. An additional <div> may solve your problem.

<div th:fragment="topbar">
  <!--fragment div start-->
  <div class="top-bar">
    <div class="container">
      <div class="row">
        <div class="col-sm-6 col-xs-4">
          <div class="top-number">
            <p><i class="fa fa-phone-square"></i> +0123 456 70 90</p>
          </div>
        </div>
        <div class="col-sm-6 col-xs-8">
          <div class="social">
            <ul class="social-share">
              <li><a href="#"><i class="fa fa-facebook"></i></a>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
    <!--/.container-->
  </div>
  <!--/.top-bar-->
</div>
<!--fragment div end-->
like image 67
Tanmoy Mandal Avatar answered Jan 13 '23 23:01

Tanmoy Mandal