【发布时间】:2018-05-17 13:18:43
【问题描述】:
我正在尝试通过循环遍历列表来为我的页面中的内容动态生成链接,但出现“解析错误”
我尝试了https://www.thymeleaf.org/doc/articles/standardurlsyntax.html中提到的:
<a th:href="@{/order/{id}/details(id=3,action='show_all')}">
代码:
<li th:each="param : ${paramList}">
<span th:text="${placeholder}">This is displaying the value of placeholder correctly</span>
<!-- The value I am trying to achieve is href="/member/team/ValueFromPlaceholderVariable?team=TeamName&page=PageName" -->
<a th:href="@{/member/team/{PlaceName}(PlaceName=${placeholder},team=${param.TeamName},page=${param.PageName})}">Page</a>
</li>
如何生成 href 链接?
【问题讨论】:
-
你可以试试
<a th:href="@{/member/team/__${placeholder}__(team=${param.TeamName},page=${param.PageName})}">Page</a> -
你所拥有的看起来是正确的。究竟是什么错误?
-
@Metroids:链接库“/member/team/{PlaceName}”不能是上下文相关的(/...),除非用于执行引擎的上下文实现了 org.thymeleaf.context.IWebContext界面(模板:“介绍” - 第 12 行,第 16 列)
-
如果我在开头删除斜线,那么它似乎可以工作。我需要更多地测试它。
<a th:href="@{member/team/{PlaceName}(PlaceName=${placeholder},team=${param.TeamName},page=${param.PageName})}">Page</a>
标签: spring-boot thymeleaf