I am using spring boot with hibernate and I want to use pagination in my project. I have searched on google and saw many examples but I am unable to implement it in my proje
I have implemented pagination in spring boot. Below is my Repository.
@Repository("userRepository")
public interface UserRepository extends PagingAndSortingRepository {
}
Below is my Controller.
@Controller
public class SampleController {
@Autowired
private UserRepository repository;
@GetMapping("/userview")
public String getEmployees(@PageableDefault(size = 1) Pageable pageable,
Model model) {
Page page = repository.findAll(pageable);
model.addAttribute("page", page);
return "userdetail";
}
}
Below is the view,for that I have used thymeleaf.
USER DETAILS
ID
Name
Last Name
Email
Role