thymeleaf使⽤onclick传递参数
转⾃
Springboot中使⽤thymeleaf,在⽤户列表中希望点击删除按钮就删除当前⽤户,需要传递当前⽤户的id。
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>id</th>
<th>⽤户名</th>
<th>密码</th>
<th>电话</th>
<th>邮箱</th>
<th>操作</th>
</tr>
</thead>
<tbody >
<tr th:each="user : ${userlist}">
<td th:text="${user.userID}"></td>
<td th:text="${user.username}"></td>
<td th:text="${user.password}"></td>
<td th:text="${user.phone}"></td>
<td th:text="${ail}"></td>
<td><button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#updateModal" th:onclick="'javascript: updateUser('+${user.use
<!--th:onclick后即为传递参数,在js中就可以接收-->
<button type="button" class="btn btn-danger btn-sm"  th:onclick="'javascript:deleteUser('+${user.userID}+')' ">删除</button>
thyme</td>
</tr>
</tbody>
</table>

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。