[英]how to pass a value using thymeleaf to data of bootstrap?
我想使用Thymeleaf將值傳遞給Bootstrap中的數據。
我不知道該怎么做。 你能幫助我嗎?
<tr th:each="car : ${lCars}" class="succes">
<td th:text="${car.id}"></td>
<td th:text="${car.name}"></td>
<td align="center">
<button type="button" class="btn btn-primary"
data-toggle="modal" data-target="#editar" title="Edit"
data-id= "th:text="${car.id}"" <!-- I want to pass this value on to the data, but this way doesn't work -->
data-name="myCar" <!-- If I send a simple word, works well -->
<span class="glyphicon glyphicon-pencil"></span> Edit
</button>
</td>
</tr>
以下行沒有意義:data-id =“ th:text =” $ {car.id}“”
該行應寫為:
data-id="" th:attr="data-id=${car.id}"
如果您希望data-id具有一些默認值,例如“ example-id”,請執行以下操作:
data-id="example-id" th:attr="data-id=${car.id}"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.