Answer the question
In order to leave comments, you need to log in
Thymeleaf, how to add a default value for a parameter if it's missing when a link is clicked?
Please tell me how using Thymeleaf. add a parameter to a link with a default value only if it's not already in the link?
This is how I add a new parameter, but this link must also add the sortDir and sortField parameters with default values if they are missing .
<ul th:with="urlBuilder=
${T(org.springframework.web.servlet.support.ServletUriComponentsBuilder).fromCurrentRequest()}"
<li><a th:href="@{${urlBuilder.replaceQueryParam('category', 'vehicles').build().toUriString()}}"
class="dropdown-item" href="#" >Show all</a></li>
Answer the question
In order to leave comments, you need to log in
Thymeleaf, how to add a default value for a parameter if it's missing when a link is clicked?
.on('click', function(){})
or .click()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question