I would like to generate links in my html page using thymeleaf with the address http://localhost:8080/book/{key}. However, it always shows the address with an extra question mark instead http://localhost:8080/book/?{key}. Is it because my syntax is wrong in the html page? How can I change my html page so that it does not show the question mark?
P.S. key comes from a list of keys provided in a list of existingTitle
<ol style="padding-top:1em">
<span th:each="t : ${existingTitle}">
<a th:href="@{book/(${t[0]})}">
<li th:text="${t[1]}" style="padding-top:0.5em"></li></a>
</span>
</ol>
CodePudding user response:
It's because you pass t[0] as parameter and not as path. Check absolute path and adding parameters sections in documentation.
So your link should like this
<a th:href="@{book/{id}(id=${t[0]})}">
or
<a th:href="@{book/${t[0]}}">
CodePudding user response:
Just to add on to Justinas's post, and my subsequent reply, using
"a th:href="@{book/${t[0]}}"" causes the value of t[0] to be gibberish, like in this image :


