jpa 排序分页


repository

1
2
3
4
5
@Repository
public interface UserRepository extends PagingAndSortingRepository<User, Long> {

Page<User> findAll(Pageable pageable);
}

controller

1
2
3
4
5
Page<User> users = userRepository.findAll(pageable);
List<UserProfile> result = new ArrayList<>();
for (User user : users) {
result.add(new UserProfile(user));
}

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×