title: got bug for many-page pagination
body: <p>i was creating the many-page pagination and i found out my page 36 doesnt show the number for pagination only shows previous and next page.(i got 40 total pages) and i faced the same bug when my total page record is 20 and the bug occurs at page 16. can anyone tell me which of the part logic goes wrong? thanks in advance</p>
  <p>Here is the code</p>
  <pre><code>  &lt;th:block th:if=&quot;${totalPages &lt;= 10}&quot;&gt;
                          &lt;li th:each=&quot;i: ${#numbers.sequence(1, totalPages)}&quot;&gt;&lt;a th:if=&quot;${currentPage != i}&quot;
                                  th:href=&quot;@{'/page/' + ${i}+ '?sortField=' + ${sortField} + '&amp;sortDir=' + ${sortDir}}&quot;
                                  class=&quot;page-link&quot;&gt;[[${i}]]&lt;/a&gt;
                          &lt;/li&gt;
                      &lt;/th:block&gt;
                      &lt;th:block th:if=&quot;${totalPages &gt; 10}&quot;&gt;
                          &lt;th:block th:if=&quot;${currentPage &lt;= 5 || currentPage &gt; totalPages - 4}&quot;&gt;
                              &lt;li th:each=&quot;i: ${#numbers.sequence(1, 5)}&quot;&gt;
                                  &lt;a th:if=&quot;${currentPage != i}&quot;
                                      th:href=&quot;@{'/page/' + ${i}+ '?sortField=' + ${sortField} + '&amp;sortDir=' + ${sortDir}}&quot;
                                      class=&quot;page-link&quot;&gt;[[${i}]]&lt;/a&gt;
                              &lt;/li&gt;
                              &lt;a th:href=&quot;@{'/page/' + 6 + '?sortField=' + ${sortField} + '&amp;sortDir=' + ${sortDir}}&quot;
                                  class=&quot;page-link&quot;&gt;...&lt;/a&gt;
  
                              &lt;li th:each=&quot;i: ${#numbers.sequence(totalPages - 4, totalPages)}&quot;&gt;
                                  &lt;a th:if=&quot;${currentPage != i}&quot;
                                      th:href=&quot;@{'/page/' + ${i}+ '?sortField=' + ${sortField} + '&amp;sortDir=' + ${sortDir}}&quot;
                                      class=&quot;page-link&quot;&gt;[[${i}]]&lt;/a&gt;
                              &lt;/li&gt;
                          &lt;/th:block&gt;
  
                          &lt;th:block th:if=&quot;${currentPage &gt; 5 &amp;&amp; currentPage &lt; totalPages - 4}&quot;&gt;
                              &lt;a th:href=&quot;@{'/page/' + ${currentPage - 5} + '?sortField=' + ${sortField} + '&amp;sortDir=' + ${sortDir}}&quot;
                                  class=&quot;page-link&quot;&gt;...&lt;/a&gt;
  
                              &lt;li th:each=&quot;i: ${#numbers.sequence(currentPage - 4, currentPage + 4)}&quot;&gt;
                                  &lt;a th:if=&quot;${currentPage != i}&quot;
                                      th:href=&quot;@{'/page/' + ${i}+ '?sortField=' + ${sortField} + '&amp;sortDir=' + ${sortDir}}&quot;
                                      class=&quot;page-link&quot;&gt;[[${i}]]&lt;/a&gt;
                              &lt;/li&gt;
  
  
                              &lt;a th:href=&quot;@{'/page/' + ${currentPage + 5} + '?sortField=' + ${sortField} + '&amp;sortDir=' + ${sortDir}}&quot;
                                  class=&quot;page-link&quot;&gt;...&lt;/a&gt;
                          &lt;/th:block&gt;
  
  
                      &lt;/th:block&gt;
  </code></pre>