Spring HATEOS 分页响应对象显示不正确的最后一个链接

问题描述 投票:0回答:0

我正在尝试构建自定义响应对象,但在最终响应中,我得到的 last 元素的链接不正确。

有什么想法吗?

要求:

/searchx?page=2&size=5&total_required=true

回应:

 "_links": {
    "first": {
        "href": "http://localhost:8080/v1/xx/fxy/x1/searchx?total_required=true&page=0&size=5"
    },
    "prev": {
        "href": "http://localhost:8080/v1/xx/fxy/x1/searchx?total_required=true&page=1&size=5"
    },
    "self": {
        "href": "http://localhost:8080/v1/xx/fxy/x1/searchx?total_required=true&page=2&size=5"
    },
    "last": {
        "href": "http://localhost:8080/v1/xx/fxy/x1/searchx?total_required=true&page=2&size=5"
    }
},

这里是我的页面资源组装器

        Page<MyData> pageRs = new PageImpl<>(data, pageable, total);

    response.setData(pageRs.getContent());
    PagedModel<MyModel> responseModels = pagedResourcesAssembler.toModel(pageRs, datAssembler);
    response.setLinks(responseModels.getLinks());

spring spring-boot spring-hateoas
© www.soinside.com 2019 - 2024. All rights reserved.