leo
leo

Reputation: 3749

How to create a dynamic URL fragment identifiers in Thymeleaf?

It is possible to create a url in Thymeleaf to an URL fragment identifier:

<a th:href="@{/search#item-25(q=${query},all='true')}">
    more...
</a>

However i want to dynamically create the fragment identifier (such that I can link to #item-n), something like (not working code):

<a th:href="@{/search#item-${n}(q=${query},all='true')}">
    more...
</a>

How can this achieved with Thymeleaf?

Upvotes: 1

Views: 837

Answers (1)

Marek Raki
Marek Raki

Reputation: 3136

Try this:

@{${'/search#item-' + n}(q=${query},all='true')}

Upvotes: 5

Related Questions