2017-09-22 50 views
0

我寫了一個thymleaf div,我想在另一個thymleaf模板頁面中包含。將themleaf模板div包括在另一個

但是我得到這個錯誤:org.thymeleaf.exceptions.TemplateInputException:錯誤解決模板「片段/分頁」,模板可能不存在或可能不被任何配置的模板解析器來訪問(managetasks)

下面是主要的網頁代碼

<!DOCTYPE html> 
<html lang="en" xmlns:th="http://www.thymeleaf.org"> 

    <body> 
    <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables"> 
     <thead> 
     <tr> 
      <th>ID</th> 
      <th>Type</th> 
      <th>Instance</th> 
      <th>Status</th> 
      <th>Options</th> 
     </tr> 
     </thead> 
     <tbody> 
     <tr data-task-id="" th:each="task : ${tasks}" th:attr="data-task-id=${task.id}"> 
      <td data-column="taskId" th:text="${task.id}">1123</td> 
      <td th:text="${task.task.taskType}"></td>      
      <td th:text="${task.instance.name}">192.168.100.5</td> 
      <td th:text="${task.status}">Done</td> 
      <td><button class="btn btn-info infoButton" data-toggle="model" th:attr="data-target='#taskDetailModel'+${task.id}">Detail</button></td> 
     </tr> 
     </tbody> 
    </table> 
    <!-- Pagination Bar --> 
    <div th:replace="fragments/pagination::paginationbar"></div> 
</body> 
</html> 

和我想包括頁面的div是在這裏下面:

<!DOCTYPE html> 
<html lang="en" xmlns:th="http://www.thymeleaf.org"> 
<head> 
    <meta charset="UTF-8"> 
    <title>Title</title> 
</head> 
<body> 
<div th:fragment="paginationbar"> 
    <div> 
     <ul class='pagination pagination-centered'> 
      <li th:class="${page.firstPage}?'disabled':''"> 
       <span th:if='${page.firstPage}'>← First</span> 
       <a th:if='${not page.firstPage}' th:href='@{${page.url}(page=0,size=${page.size})}'>← First</a> 
      </li> 
      <li th:class="${page.hasPreviousPage}? '' : 'disabled'"> 
       <span th:if='${not page.hasPreviousPage}'>«</span> 
       <a th:if='${page.hasPreviousPage}' th:href='@{${page.url}(page=${page.number-2},size=${page.size})}' title='Go to previous page'>«</a> 
      </li> 
      <li th:each='item : ${page.items}' th:class="${item.current}? 'active' : ''"> 
       <span th:if='${item.current}' th:text='${item.number}'>1</span> 
       <a th:if='${not item.current}' th:href='@{${page.url}(page=${item.number-1},size=${page.size})}'><span th:text='${item.number}'>1</span></a> 
      </li> 
      <li th:class="${page.hasNextPage}? '' : 'disabled'"> 
       <span th:if='${not page.hasNextPage}'>»</span> 
       <a th:if='${page.hasNextPage}' th:href='@{${page.url}(page=${page.number},size=${page.size})}' title='Go to next page'>»</a> 
      </li> 
      <li th:class="${page.lastPage}? 'disabled' : ''"> 
       <span th:if='${page.lastPage}'>Last →</span> 
       <a th:if='${not page.lastPage}' th:href='@{${page.url}(page=${page.totalPages - 1},size=${page.size})}'>Last →</a> 
      </li> 
     </ul> 
    </div> 
</div> 
</body> 
</html> 

回答

0

問題解決了,我在

<div th:replace="fragments/pagination::paginationbar"></div> 

文件夾名稱給人錯誤的文件夾名fargments而不是片段,所以沒有什麼是錯的代碼