<!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>
</body>
</html>