I have the following method in my controler:
@RequestMapping(value = "/", method = RequestMethod.GET)
public ModelAndView home(ModelMap model) {
Page<Postagem> page = postagemService.findByPagination(0, 5);
model.addAttribute("page", page);
model.addAttribute("urlPagination", "/page");
return new ModelAndView("posts.html", model);
}
And the following page where I use thymeleaf to display the data:
<div>
<span th:each="p: ${#numbers.sequence(1,page.totalPages)}" >
<span>
<a href="#" th:href="@{/page/{p}(p=${p})}" style="text-decoration: none">
<span th:text="${p}" class="btn-group btn-lg btn-primary"></span>
</a>
</span>
</span>
</div>
The question is how to get the value of urlPagination that I sent by the controller and put in place of the page stretch in that url:
th:href="@{/page/{p}(p=${p})}"
I've posted a similar question on this link Problems with url using thymeleaf . but in this case, it was just a parameter!