@RequestMapping("/toUserList")
public String toUserList(Model model){
List<User> userList = userServiceImpl.queryAllByLimit(0, 5);
PageInfo pageInfo = new PageInfo(userList, 5);
model.addAttribute("pageInfo", pageInfo);
return "user-list1";
}
@RequestMapping("/toUserListByPage")
public String toUserList(Model model, String pageNum){
List<User> userList = userServiceImpl.queryAllByLimit(Integer.valueOf(pageNum), 5);
PageInfo pageInfo = new PageInfo(userList, 5);
model.addAttribute("pageInfo", pageInfo);
return "user-list1";
}
<ul class="pagination" th:object="${pageInfo}">
<li th:class="${pageInfo.prePage} == 0 ? 'disabled':'' ">
<!-- 上一页-->
<a th:href="${pageInfo.prePage} == 0 ? 'javascript:void(0)':@{'/toUserListByPage?pageNum='+${pageInfo.prePage}}" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<li th:each="pageNum : ${pageInfo.navigatepageNums}"><a
th:href="@{'/toUserListByPage?pageNum='+${pageNum}}">[[${pageNum}]]</a></li>
<li th:class="${pageInfo.nextPage} == 0 ? 'disabled':'' ">
<a
th:href="${pageInfo.nextPage} == 0 ? 'javascript:void(0)':@{'/toUserListByPage?pageNum='+${pageInfo.nextPage}}"
aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>