The style of the page is like this cotroller here, to the view total pages, now page, next page, previous information<textarea readonly="">Private String Homeinfo (model model) {page<postentity> postentities= postservice.findallbypage (0,10) ; Model.addattribute ("Posts", postentities.getcontent ()); int totalpage=postentities.gettotalpages (); int nowpage=postentities.getpageable (). Getpagenumber () +1; int prepage=nowpage>2?nowpage-1:0; int nextpage=nowpage<totalpage?nowpage+1:0; Model.addattribute ("Totalpage", totalpage); Model.addattribute ("Nowpage", nowpage); Model.addattribute ("Prepage", prepage); Model.addattribute ("NextPage", nextPage); Return render ("index"); }</textarea><textarea spellcheck="false" tabindex="0" readonly=""></textarea>1
Private String Homeinfo (modelmodel) {
2
Page < postentity > postentities = Postservice. Findallbypage (0,ten);
3
model. AddAttribute ("Posts",postentities. getcontent ());
4
int Totalpage = postentities. gettotalpages ();
5
int Nowpage = postentities. getpageable (). Getpagenumber ()+1;
6
int Prepage = Nowpage > 2 ? Nowpage - 1:0;
7
int NextPage = Nowpage < Totalpage ? Nowpage + 1:0;
8
9
model. AddAttribute ("Totalpage",totalpage);
10
model. AddAttribute ("Nowpage",nowpage);
11
model. AddAttribute ("Prepage",prepage);
12
model. AddAttribute ("NextPage",nextPage);
13
return Render ("index");
14
}
The view version says so.<textarea readonly=""><!--paging-<div style= "Text-align:center" > <a class= " Pure-button "href="/"> Home </a> <a class=" Pure-button "th:if=" ${prepage! = 0} "th:href=" @{'/pa ge/' +${prepage} ' > Previous </a> <a class= Pure-button "th:if=" ${nextpage! = 0} "th:href=" @{'/page /' +${nextpage}} ' > Next </a> <a class= "Pure-button" th:href= "@{'/page/' +${totalpage}}" > Last < ;/a> </div></textarea><textarea spellcheck="false" tabindex="0" readonly=""></textarea>1
<!--paging -
2
< Div style="Text-align:center">
3
< a class="Pure-button"href="/"> home </a >
4
< a class="Pure-button"th:if="${prepage! = 0}"th:href="@ {'/page/' +${prepage}} '> prev </a>
5
< a class="Pure-button"th:if="${nextpage! = 0}"th:href="@{'/page/' + ${nextpage}} "> next </a>
6
< a class="Pure-button"th:href="@{'/page/' +${totalpage}}"> last </a>
7
</ Div >
From for notes (Wiz)
Springboot+thymeleaf Pure Background Rendering Lazy edition pagination