Java 使用<;a>;迭代中的标记
我需要显示一个链接列表通过列表来使用thymeleaf。 我使用以下代码成功地完成了相同的操作:Java 使用<;a>;迭代中的标记,java,html,thymeleaf,Java,Html,Thymeleaf,我需要显示一个链接列表通过列表来使用thymeleaf。 我使用以下代码成功地完成了相同的操作: <div class="col-12 col-md-6" th:each="ApplicationVO: ${ApplicationList}"> <a class="service-link shadow" title="MMIS" href="mmis.htm
<div class="col-12 col-md-6" th:each="ApplicationVO: ${ApplicationList}">
<a class="service-link shadow" title="MMIS" href="mmis.html" target="_blank"><span th:text="${ApplicationVO.applicationName} +'»'"></span></a>
</div>
我的问题是如何将链接(href)和标题作为ApplicationVO.applicationLink和ApplicationVO.displayName放在锚定标记中?我想您需要使用th:href标记:
<div class="col-12 col-md-6" th:each="ApplicationVO: ${ApplicationList}">
<a class="service-link shadow" title="MMIS" th:href="@{${ApplicationVO.applicationLink}}" target="_blank"><span th:text="${ApplicationVO.applicationName} +'»'"></span></a>
</div>
我认为您也可以像这样删除span标记:
<div class="col-12 col-md-6" th:each="ApplicationVO: ${ApplicationList}">
<a class="service-link shadow" title="MMIS" th:text="${ApplicationVO.applicationName} +'»'" th:href="@{${ApplicationVO.applicationLink}}" target="_blank"></a>
</div>
先生,th:href不起作用,尽管th:text可以起作用。制作href会使它指向而不是它的内容。事实上,我忘记了ApplicationVO.applicationLink周围的${}。我已经编辑了答案。抱歉搞混了。