<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8" />
<title>pagination fragment</title>
</head>
<body>
 <div id="paginationFragment" th:fragment="paginationFragment" >
 <div th:if="${page.totalPages>1}">
 <a th:if="!${page.firstPage}" th:href="@{${baseUrl}(p.page=1)}">&lt;&lt;</a>
 <a th:if="${page.hasPreviousPage()}" th:href="@{${baseUrl}(p.page=${page.number})}">&lt;</a>
 <span th:if="${page.number-2} > 0">...</span>
 <a th:each="i: ${#numbers.sequence(1,2)}" th:if="${page.number-2+i} > 0" th:href="@{${baseUrl}(p.page=${page.number-2+i})}" th:text="${page.number-2+i}"></a>
 <span th:text="${page.number+1}"></span>
 <a th:each="i: ${#numbers.sequence(1,2)}" th:if="${page.number+1+i} &lt; ${page.totalPages+1}" th:href="@{${baseUrl}(p.page=${page.number+1+i})}" th:text="${page.number+1+i}"></a>
 <span th:if="${page.number+3} &lt; ${page.totalPages}">...</span>
 <a th:if="${page.hasNextPage()}" th:href="@{${baseUrl}(p.page=${page.number+2})}">&gt;</a>
 <a th:if="!${page.lastPage}" th:href="@{${baseUrl}(p.page=${page.totalPages})}">&gt;&gt;</a>
 </div>
 <div th:remove="all">               
  <a href="#?p.page=1">&lt;&lt;</a>                    
  <a href="#?p.page=3">&lt;</a>
  <span>...</span>
  <a href="#?p.page=2">3</a>
  <a href="#?p.page=3">4</a>
  <span>5</span>
  <a href="#?p.page=5">6</a>
  <a href="#?p.page=6">7</a>
  <span>...</span>
  <a href="#?p.page=5">&gt;</a>
  <a href="#?p.page=7">&gt;&gt;</a> 
</div>
 </div>
</body>
</html>