user2477
user2477

Reputation: 997

Thymeleaf - Context-relative and slash ending url

<a th:href="@{'delete?id='+${user.id}}">X</a>

When I access /admin: The url become delete?id=

But when I access /admin/: The url become admin/delete?id= (that is the one I want)

So should I use Server-relative URL as an alternative in this case, or should I just assume /admin/ is a wrong URL and use

<a th:href="@{'admin/delete?id='+${user.id}}">X</a>

for /admin

Upvotes: 2

Views: 905

Answers (1)

Metroids
Metroids

Reputation: 20477

In this case, I think you should be using context relative urls. (Also, you shouldn't building urls using string concatenation -- thymeleaf supports variables.) My recommended syntax:

<a th:href="@{/admin/delete(id=${user.id})}">X</a>

Upvotes: 2

Related Questions