[英]how to pass a value using thymeleaf to data of bootstrap?
I want to use Thymeleaf to pass a value to data from Bootstrap. 我想使用Thymeleaf将值传递给Bootstrap中的数据。
I don't know how to do it. 我不知道该怎么做。 Can you help me? 你能帮助我吗?
<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>
The following line makes no sense: data-id="th:text="${car.id}"" 以下行没有意义:data-id =“ th:text =” $ {car.id}“”
That line should be written as follows: 该行应写为:
data-id="" th:attr="data-id=${car.id}"
If you want the data-id to have some default value like "example-id", do this: 如果您希望data-id具有一些默认值,例如“ example-id”,请执行以下操作:
data-id="example-id" th:attr="data-id=${car.id}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.