我正在使用Spring Boot构建REST API。问题真的很简单,如何为依赖项请求启用分页?
结果如何显示非依赖性请求http://localhost:8080/dimensionAttributes
:
{
"_embedded" : {
"dimensionAttribute" : [ {
"name" : "SollFreitag",
"description" : "Sollstunden Freitags",
"dataType" : "DEC",
"hasHistory" : true,
"hasTrigger" : null,
"allowInterface" : true,
"readOnly" : null,
"discrete" : null,
"mandatory" : false,
"_links" : {
"self" : {
"href" : "http://localhost:8080/dimensionAttributes/20"
},
"dimensionAttribute" : {
"href" : "http://localhost:8080/dimensionAttributes/20"
},
"dimension" : {
"href" : "http://localhost:8080/dimensionAttributes/20/dimension"
},
"dimensionAttributeValue" : {
"href" : "http://localhost:8080/dimensionAttributes/20/dimensionAttributeValue"
}
}
} ]
},
"_links" : {
"first" : {
"href" : "http://localhost:8080/dimensionAttributes?page=0&size=20"
},
"self" : {
"href" : "http://localhost:8080/dimensionAttributes{?page,size,sort}",
"templated" : true
},
"next" : {
"href" : "http://localhost:8080/dimensionAttributes?page=1&size=20"
},
"last" : {
"href" : "http://localhost:8080/dimensionAttributes?page=1&size=20"
},
"profile" : {
"href" : "http://localhost:8080/profile/dimensionAttributes"
},
"search" : {
"href" : "http://localhost:8080/dimensionAttributes/search"
}
},
"page" : {
"size" : 20,
"totalElements" : 35,
"totalPages" : 2,
"number" : 0
}
}
但是运行一个依赖项请求(在本例中为“ dimensionAttributeValue”)http://localhost:8080/dimensionAttributes/20/dimensionAttributeValue
,page
部分以及next
URL和其他链接都丢失了。
{
"_embedded" : {
"dimensionAttributeValue" : [ {
"chrValue" : "Mihal, Matus",
"intValue" : null,
"decValue" : null,
"datValue" : null,
"startDate" : null,
"_links" : {
"self" : {
"href" : "http://localhost:8080/dimensionAttributeValues/18993"
},
"dimensionAttributeValue" : {
"href" : "http://localhost:8080/dimensionAttributeValues/18993"
},
"lstValue" : {
"href" : "http://localhost:8080/dimensionAttributeValues/18993/lstValue"
},
"dimensionAttribute" : {
"href" : "http://localhost:8080/dimensionAttributeValues/18993/dimensionAttribute"
},
"masterData" : {
"href" : "http://localhost:8080/dimensionAttributeValues/18993/masterData"
}
}
} ]
},
"_links" : {
"self" : {
"href" : "http://localhost:8080/dimensionAttributes/1/dimensionAttributeValue?page=0,&size=1"
}
}
}