How to make pages on List<…> in HTML thymeleaf with SpringBoot

I have list with 40 elements, that I pass to html site like so: (categoryId is a ID of category that I passed from another page – 1,12,3, etc.)

@GetMapping("show-products") public String showProducts(@RequestParam Long categoryId, Model model) {     model.addAttribute("productList",productRepository.findAllByCategoryId(categoryId));     return "show-products"; } 

show-products HTML:

... <div th:each="tempProduct : ${productList)">     <a th:href="#">Test</a> </div> ... 

For now it will show all elements from list, I want to have max 10 elements on each page.

How to do such thing?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.