Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java ThymileAF:URL中的参数未被替换_Java_Spring Mvc_Thymeleaf - Fatal编程技术网

Java ThymileAF:URL中的参数未被替换

Java ThymileAF:URL中的参数未被替换,java,spring-mvc,thymeleaf,Java,Spring Mvc,Thymeleaf,我正在努力学习SpringMVC和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="${i

我正在努力学习SpringMVC和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>
  • 按钮文本
在这两个示例中,链接中的参数从未被替换。在HTML中,我总是得到类似于
roomdetails/${item.key}/${item.value}
的东西。不过,该按钮工作正常&对于循环的每次迭代,它将显示在${item.value}中的文本

有人知道为什么我不能以我想要的格式获取URL吗?从我所看到的情况来看,我正在做文档中告诉我的事情。

这应该可以:

<a href="roomdetails.html"  th:href="@{'/roomdetails/' + ${item.key} + '/' + ${item.value}}"> 

回答:


我仍然无法使URL与括号一起工作,但字符串连接在列表中起作用。@LeeTheobald Nice one,我将删除上面的一个。我没有一个开发设置来测试它,但我认为它可能是从内存中运行的。