I am beginner with Java and Spring Boot, I use Pagination
on Spring Boot, with this code I return the list of users, which I must if I want to also return the number of pages?
I know that with getTotalPages()
I can get the page count but how to return it?
@Service
public class UserService{
@Autowired
UserRepository userRepository;
public List<UserDto> findAll(PageRequest pageRequest){
Page<User> userPage = userRepository.findAll(pageRequest);
List<UserDTO> dtos = new ArrayList<UserDTO>();
//return userPage.getContent();
for (User u : userPage.toList() ) {
dtos.add(new UserDTO(u));
}
return dtos;
}
}