When I new a PageImpl Object like :
new PageImpl<CompanyEntity>(content, new PageRequest(page, size), total);
the result is not correct.
When the "size" lagger than "total" the totalElements use the "content.size" and when "size" less than "total" the totalElements use the "total".
why ?
The "totalElements" shouldn't represent the total count of elements ?
Help!
set PageRequest
page start to 0. It solved my problem.
PageRequest pageRequest = PageRequest.of(pageNo-1,pageSize,sort);
Page<T> response = new PageImpl<>(result,pageRequest,totalCount);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With