Problems to pass two parameters in the url using Thymeleaf

Asked

Viewed 667 times

0

I have next step on my controller:

 @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 show 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 take the value of urlPagination that I sent by the controller and put in place of the chunk page at that url:

th:href="@{/page/{p}(p=${p})}"  

I have posted a similar doubt on this link Problems with url using Thymeleaf. but in this case, it was only a parameter!

  • Do th:href="@{{url}/{p}(url=${urlPagination},p=${p})}" doesn’t solve?

  • And th:href="@{${urlPagination}+'/'+${p}}"?

  • @Andersoncarloswoss Your comment helped me get this link:@{/{urlPagination}/{p}( urlPagination=${urlPagination}, p=${p})} and it worked!! Thank you

  • With him answer the question partner!! And then a force found this interesting question, haha... OK?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.