【发布时间】:2014-09-29 17:27:20
【问题描述】:
我还在学习 Thymeleaf、Bootstrap 和 JQuery,所以请原谅我的无知。我有一个以 Thymeleaf 和 Bootstrap 作为 UI 的 spring-boot 应用程序。我有一个用户列表,我在表格中显示并希望对其进行编辑。我目前的想法是,用户可以选择行上的图标,并将该记录填充到模式对话框表单中,可以通过调用对其进行更新。不确定这是否是最好的,但这是我现在的位置。
这是我的html:
<div class="container">
<div class="well well-lg">
<div class="container-fluid">
<h5>CNET OFAC Users</h5>
<div th:if="${userList != null and not #lists.isEmpty(userList)}">
Found <span th:text="${#lists.size(userList)}"></span> Users
</div>
<div th:if="${userList == null or #lists.isEmpty(userList)}">
<div>"No Users were found"</div>
</div>
<table class="table table-striped">
<thead>
<tr>
<th>UserName</th>
<th>Company</th>
<th>Role</th>
<th>Active</th>
<th></th>
</tr>
</thead>
<tbody>
<tr th:each="user : ${userList}">
<td th:text="${user.username}"></td>
<td th:text="${user.companyName}"></td>
<td th:text="${user.roles[0].authorities}"></td>
<td th:text="${user.enabled}"></td>
<td><a data-toggle="modal" data-target="#editModal"><span class="glyphicon glyphicon-edit"></span></a></td>
</tr>
</tbody>
</table>
<button data-target="#loginModal" data-toggle="modal" class="btn btn-default">Add User</button>
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</div>
</div>
</div>
其中包括更新表格: × 编辑用户
<div class="modal-body">
<form class="form-horizontal bv-form" action="addUser" th:action="@{/addUser}" th:object="${user}" method="put" id="loginForm">
<div class="form-group">
<label class="col-md-3 control-label">Username</label>
<div class="col-md-5">
<input type="text" name="username" class="form-control" />
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Password</label>
<div class="col-md-5">
<input type="password" name="password" class="form-control" />
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Confirm Password</label>
<div class="col-md-5">
<input type="password" name="cpassword" class="form-control" />
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Company</label>
<div class="col-md-5">
<input type="text" name="companyName" class="form-control" />
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Status</label>
<div class="col-md-5">
<select class="form-control" name="enabled" th:field="*{enabled}">
<option value="true">Active</option>
<option value="false">Inactive</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-5 control-label">
<button class="btn btn-default" type="submit">Update</button>
</div>
</div>
</form>
</div>
</div>
</div
我被卡住的地方是如何使用单击编辑按钮的行上的记录填充此模式。使用该记录值填充模式的最佳方法是什么,以便我可以将其提交给我的 spring-mvc 控制器进行更新?
【问题讨论】:
标签: twitter-bootstrap-3 thymeleaf