th:href Thymeleaf redirect url with path variables and object id's with Spring MVC
<p>So I'm trying to redirect the entire url with a th:href, but it is adding characters that I don't want.</p>

<p>My current url is this</p>

<pre><code>http://localhost:8080/viewCourse/post/5
</code></pre>

<p>And I'm trying to backtrack to the course the post was a part of, which is </p>

<pre><code>http://localhost:8080/viewCourse/1
</code></pre>

<p>So currently this is what my html looks like </p>

<pre><code>&lt;a th:href="@{'/viewCourse/'(${post.course.id})}"&gt;&lt;span th:text="${post.course.name}"&gt;&lt;/span&gt;&lt;/a&gt;
</code></pre>

<p>And this is the url I get</p>

<pre><code>http://localhost:8080/viewCourse/?1
</code></pre>

<p>And the Id is correct, but I'm not sure why the <code>?</code> is there.</p>

<p>I've also tried this</p>

<pre><code>&lt;a th:href="@{'/viewCourse/'(id=${post.course.id})}"&gt;&lt;span th:text="${post.course.name}"&gt;&lt;/span&gt;&lt;/a&gt;
</code></pre>

<p>Which gives me this </p>

<pre><code>http://localhost:8080/viewCourse/?id=1
</code></pre>

<p>If anybody can see how I can fix this and let me know that would be great, thanks in advance.</p>