在微服务环境中,spring-data-jpa分页查询无法回填查询数据

时间:2019-03-02 09:02:51

标签: spring-boot spring-data-jpa spring-data spring-cloud

在客户端-服务器上的分页查询请求资源服务器,服务器资源查询结果并返回org.springframework.data.domain.Page接口。我不能在客户端服务器上使用它。我将其封装为一个实体对象,但是问题是条件查询的参数无法传递。

资源服务器

@Override
    public Page<RoleEntity> findAllPage(int page, int pageSize) {
ExampleMatcher.GenericPropertyMatchers.startsWith());
        return roleDao.findAll(PageRequest.of(page-1, pageSize,Sort.by(Sort.Order.desc("id"))));
    }

客户端服务器分页

<nav aria-label="..." th:fragment="simplePage(jpaPageTool)">
    <ul class="pagination">
        <li class="page-item" th:classappend="${jpaPageTool.isFirstPage}?'disabled':''">
            <a class="page-link" th:href="@{${#request.getRequestURI()}(page=${jpaPageTool.page-1})}" aria-label="Previous">
                <span aria-hidden="true">&laquo;</span>
                <span class="sr-only">Previous</span>
            </a>
        </li>
        <div th:text="${#request.getQueryString()}"></div>

        <th:block th:if="${jpaPageTool.totalPages < 10}">
            <th:block th:each="pageNo : ${#numbers.sequence(1, jpaPageTool.totalPages)}">
            <li class="page-item " th:classappend="${jpaPageTool.page == pageNo}?'active':''">
                <a class="page-link" th:href="@{${#request.getRequestURI()}(page=${pageNo})}"  th:text="${pageNo}"></a>
            </li>
            </th:block>
        </th:block>


        <li class="page-item" th:classappend="${!jpaPageTool.isLastPage}?'disabled':''">
            <a class="page-link" th:href="@{${#request.getRequestURI()}(page=${jpaPageTool.page+1})}" aria-label="Next">
                <span aria-hidden="true">&raquo;</span>
                <span class="sr-only">Next</span>
            </a>
        </li>
    </ul>
</nav>

如何传递条件查询的参数?

  

org.springframework.boot:spring-boot-starter-data-jpa:2.1.2。发布        org.springframework.boot:spring-boot-starter-web:2.1.2.RELEASE        org.springframework.cloud:spring-cloud-启动的oauth2:2.1.1.Rosease

0 个答案:

没有答案