Home > Software engineering >  After parsing a valid expression, there is still more data in the expression pageCount
After parsing a valid expression, there is still more data in the expression pageCount

Time:09-27

I'm making an E-commerce website and in the products section (inside admin), I was trying to display only 10 products per page. I'm new to Spring and while writing the code, I encountered an error (given in title) when trying to add the next page button. However, the code works fine with the Previous button and all the page numbers. Here's my code for the pagnation section:

<nav class="mt-3" th:if="${count > perPage}">
        <ul class="pagination">
            <li class="page-item" th:if="${page > 0}">
                <a th:href="@{${#httpServletRequest.requestURI}}   '?page=__${page-1}__'" class="page-link">Previous</a>
            </li>
            <li class="page-item" th:each="number: ${#numbers.sequence(0, pageCount-1)}" th:classappend="${page==number} ? 'active' : ''">
                <a th:href="@{${#httpServletRequest.requestURI}}   '?page=__${number}__'" class="page-link" th:text="${number 1}"></a>
            </li>
            <li class="page-item" th:if="${page pageCount-1}">
                <a th:href="@{${#httpServletRequest.requestURI}}   '?page=__${page 1}__'" class="page-link">Next</a>
            </li>
        </ul>
    </nav>

The first 2 li's work fine and I get the list of pages and also the previous button. But on adding the Next button, I get the error mentioned above.

CodePudding user response:

First of all, please always provide the actual error message. Otherwise we are just guessing.

My guess is that th:if expects a boolean expression and what you have doesn't look like boolean to me: th:if="${page pageCount-1}"

Change that to something like page == pageCount-1, but again depends on what you want to display there

  • Related