Reputation: 412
I have a Spring Boot with Thymeleaf project and I'm having trouble writing a button's onclick. I want the resulting url to be e.g. /owners/1/edit
. I've tried a number of concatenations the latest being:
th:onclick="'window.location.href=\'/owners/{id}/edit(id=${owner.id})\''"
...but it doesn't evaluate properly, displaying only /owners/{id}/edit(id=${owner.id})
Any ideas?
Upvotes: 0
Views: 7386
Reputation: 957
Use <a>
tag instead of onClick
.
Your code will look something like this -
<a th:href="@{/owners/{id}/edit(id=${owner.id})}">
<button type="button"> some button text </button>
</a>
Upvotes: 2