后端controller层
@RequestMapping("/comment_manage")
public String comment_managePage(Model model) {
List<Comment> l = commentService.selectAllList();
model.addAttribute("commentList", l);
return "comment_manage";
}
Thymeleaf
我们也可以使用th:each="s,status:${students}"方式遍历,就可以把状态放在status里面了,
同时还可以用th:class="${stauts.even}?'even':'odd'"来判断奇偶。
status里面包含的信息大致如下:
属性说明index从0开始的索引值
count从1开始的索引值
size集合内元素的总量
current当前的迭代对象
even/odd boolean类型的,用来判断是偶数个还是奇数个
firstboolean类型,判断是否为第一个
lastboolean类型,判断是否为最后一个
img、onclick
<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>commentId</th>
<th>图片</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr th:each="info,infoStat:${commentList}">
<td th:text="${infoStat.index}"></td>
<td th:text="${info.commentId}"></td>
<td>
<div class="box-body no-padding">
<ul class="users-list clearfix">
<img src="images/undefine.jpg"
th:src="@{'images/'+${info.imagePath}}"
style="width:40px; height:40px" alt="User Image">
</ul>
</div>
</td>
<td>
<div class="btn-group">
<button th:onclick="modifyComment([[${info.commentId}]]);"
type="button" class="btn btn-info" data-toggle="modal"
data-target="#modal-default">修改</button>
<button th:onclick="deleteComment([[${info.commentId}]]);"
type="button" class="btn btn-success">删除</button>
</div>
</td>
</tr>
</tbody>
</table>
switch
<tr th:each="info,infoStat:${purchase_done_list}">
<td th:text="${infoStat.index}"></td>
<td th:text="${info.orderId}"></td>
<td th:text="${info.sellerId}"></td>
<td th:text="${info.goodId}"></td>
<td th:text="${info.purchaserId}"></td>
<td th:text="${info.addressId}"></td>
<td th:switch="${info.shippingMethod}">
<p th:case="1">顺丰</p>
<p th:case="2">圆通</p>
<p th:case="3">中通</p>
<p th:case="4">申通</p>
<p th:case="*">其他</p>
</td>
<td th:switch="${info.shippingMethod}">
<p th:case="1">网点自提</p>
<p th:case="2">送货上门</p>
<p th:case="*">其他</p>
</td>
<td th:text="${info.usePoint == true}?'是':'否'"></td>
<td th:switch="${info.orderState}">
<p th:case="0">未发货</p>
<p th:case="1">物流中</p>
<p th:case="2">确认收货</p>
<p th:case="3">退货</p>
<p th:case="4">换货</p>
<p th:case="5">维修</p>
<p th:case="*">其他</p>
</td>
<td th:text="${info.gainPoint}"></td>
<td th:text="${info.createDate}"></td>
<td>
<div class="btn-group">
<span href="#" class="btn-success new-tag">详情</span>
<span th:onclick="deleteOrder([[${info.orderId}]]);"
type="button"
class="btn-danger new-tag">删除</span>
</div>
</td>
</tr>