我正在使用 PageImpl 类将页面转换为新页面,但 totalpages 属性的默认值为 0。我想将 totalPages 设置为特定数字。有可能改变它吗?
代码
public Page<InformationDTO> getInformationById(String classId, int page, int size) {
Pageable pageable = PageRequest.of(page, size);
List<Information> InformationList = informationRepository.findByClassIdOrderByCreateDateDesc(classId, pageable).getContent();
List<InformationDTO> InformationDTOList = new ArrayList<>();
if(!InformationList.isEmpty()){
for (Information information: informationList){
informationDTOList.add(new InformationDTO(information));
}
}
return new PageImpl<InformationDTO>(informationDTOList,pageable,informationList.size());
}