一、Controller
/**
* 订单列表
* @param page 第几页
* @param size 一页条数
* @return
* **/
@GetMapping("/list")
public ModelAndView List (@RequestParam(value = "page" ,defaultValue = "1") Integer page ,
@RequestParam(value = "size", defaultValue = "10") Integer size ,
Map<String,Object> map){
PageRequest request = new PageRequest(page -1 ,size);
Page<OrderDTO> orderDTOPage = orderService.findAll(request);
map.put("orderDTOPage",orderDTOPage);
map.put("currentPage",page);
map.put("size", size);
return new ModelAndView("order/list" , map);
}
二、service
/***
*查询全部顾客订单
*/
public interface OrderService {
Page<OrderDTO> findALL(Pageable pageable)
}
三、templates/order
<html>
<head>
<meta charset="utf-8">
<title>卖家商品列表</title>
<link href="https://cdn.bootcss.com/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>订单ID</th>
<th>顾客姓名</th>
<th>顾客手机号</th>
<th>订单地址</th>
<th>订单金额</th>
<th>订单状态</th>
<th>支付状态</th>
<th>创建时间</th>
<th colspan="2">操作</th>
</tr>
</thead>
<tbody>
<#list orderDTOPage.content as orderDTO>
<tr>
<td>${orderDTO.orderId}</td>
<td>${orderDTO.buyerName}</td>
<td>${orderDTO.buyerPhone}</td>
<td>${orderDTO.buyerAddress}</td>
<td>${orderDTO.orderAmount}</td>
<td>${orderDTO.orderStatus}</td>
<td>${orderDTO.payStatus}</td>
<td>${orderDTO.createTime}</td>
<td>详情</td>
<td>取消
<#if orderDTO.getOrderStatusEnum().message != "已取消" >
<a href="/sell/seller/order/cancel?orderId=${orderDTO.orderId}">取消</a>
</#if>
</td>
</tr>
</#list>
</tbody>
</table>
</div>
<#--分页-->
<div class="col-md-12 column">
<ul class="pagination pull-right">
<#if currentPage lte 1 >
<li class="disabled"><a href="#">上一页</a></li>
<#else >
<li><a href="/sell/seller/order/list?page=${currentPage - 1 }&size=${size}">上一页</a></li>
</#if>
<#list 1..orderDTOPage.getTotalPages() as index>
<#if currentPage == index>
<li class="disabled"><a href="#">${index}</a></li>
<#else >
<li><a href="/sell/seller/order/list?page=${index}&size=${size}">${index}</a></li>
</#if>
</#list>
<#if currentPage gte orderDTOPage.getTotalPages() >
<li class="disabled"><a href="#">下一页</a></li>
<#else >
<li><a href="/sell/seller/order/list?page=${currentPage + 1 }&size=${size}">下一页</a></li>
</#if>
</ul>
</div>
</div>
</div>
</body>
</html>
结果运行 显示: