我有这个Thymeleaf模板,我想在href元素中添加guardianId,以生成类似http://localhost:8080/guardian/delete/8665的URL,但我却得到了这个http://localhost:8080/guardian/delete/ $%7Bguardian.id%7D
<tr th:each="guardian : ${guardians}">
<td class="col_id" th:text="${guardian.id}" ></td><!-- ID -->
<td class="col_name" th:text="${guardian.name}"></td><!-- NAME -->
<td class="col_name" th:text="${guardian.surName}"></td><!-- SURNAME -->
<td class="col_name" th:text="${guardian.description}"></td><!-- DESCRIPTION -->
<td class="col_name" th:text="${guardian.mobile}"></td><!-- MOBILE -->
<td class="col_name" th:text="${guardian.email}"></td><!-- EMAIL -->
<td class="col_name" >
<i class="fa fa-pencil-square-o" aria-hidden="true"></i>
</td><!-- EDIT -->
<td class="col_name" >
<a href="/guardian/delete/${guardian.id}" >
<i class="fa fa-times" aria-hidden="true"></i>
</a>
</td><!-- DELETE -->
</tr>
我也尝试了
<a href="@{/guardian/delete/${guardian.id}}" >
,结果相同:-( 最佳答案
我不认识Thymeleaf,但我想您可以在此页面上找到解决方案。
Thymeleaf - Link (URL) expressions
尝试这样。
<a href="@{/guardian/delete/${guardian.id}}" >
关于javascript - Thymeleaf 如何在href中添加变量,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42716325/