Thymeleaf:URL中的参数未被替换

Lee*_*ald 2 java spring-mvc thymeleaf

我正在努力学习Spring MVC和Thymeleaf.我有以下HTML部分打印出一个链接和一个按钮:

<ul th:each="item : ${typesMap}">
  <li>
    <a href="roomdetails.html" th:href="@{/roomdetails/${item.key}/${item.value}}">Linky</a>
    <button type="button" th:text="${item.value}">Button Text</button>
  </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

在这两个示例中,链接中的参数永远不会被替换.我总是最终roomdetails/${item.key}/${item.value}得到HTML中的一些东西.该按钮工作正常,并将显示在循环的每次迭代中在$ {item.value}中找到的文本.

有谁知道为什么我不能以我想要的格式获取URL?从我所看到的,我正在做文档告诉我的内容.

hut*_*oid 7

这应该工作:

<a href="roomdetails.html"  th:href="@{'/roomdetails/' + ${item.key} + '/' + ${item.value}}"> 
Run Code Online (Sandbox Code Playgroud)