controller
@GetMapping(value = "/page")
public String findGoodsPage(Model model, @RequestParam(value="pageNum") String pageNum){
Page<Goods> pages=((pageNum),20,"commentNum");
if(pageNum==null){
pageNum="1";
}
int pagenum=(pageNum);
("page",pages);
("pageNum",pagenum);
("totalPages",());
("totalElements",());
return "list";
}
thymeleaf中的html页面:
<table>
<tr>
<td><a th:href="@{/goods/page?pageNum=0}">首页</a></td>
<td th:switch="${pageNum}">
<p th:case="1"> <a th:href="@{/goods/page?pageNum=1}">上一页</a></p>
<p th:case="*"><a th:href="@{/goods/page(pageNum=${pageNum-1})}">上一页</a></p>
</td>
<td th:switch="${pageNum}">
<p th:case="${totalPages}"><a th:href="@{/goods/page(pageNum=${totalPages})}">下一页</a></p>
<p th:case="*"><a th:href="@{/goods/page(pageNum=${pageNum+1})}">下一页</a></p>
</td>
<td><a th:href="@{/goods/page(pageNum=${totalPages})}">尾页</a></td>
</tr>
</table>