Itdragon Blog with Java implementation of the article content on a next function, logic and pagination is not the same. The effect is the same as at the bottom of this page. The spring data JPA SQL statement is used to implement the feature SQL statement query is the previous and next spring data JPA for this database you need to add nativequery=true if you want to execute a native SQL statement
The DAO layer code is as follows
Copy
@Query (value= "SELECT *" Xlblog WHERE ID in (SELECT case SIGN (ID-? 1) > 0 "
+" THEN MIN (ID) when SIGN (ID- ? 1) < 0 THEN MAX (ID) end as ID from Xlblog WHERE ID <> 1 "
+" GROUP by SIGN (ID-? 1) Order BY SIGN (ID-? 1) ORDER by ID ASC ", nativequery=true)
list<blog> Fetchnearblogsbyid (Long ID);
The Service layer code is as follows
Copy
Public list<blog> Findidandtitle (Long ID) {return
Blogdao.fetchnearblogsbyid (ID);
}
The Controller layer code is as follows
Copy
list<blog> blogurls = Blogservice.findidandtitle (long.valueof (blogId));
Model.addattribute ("Blogurls", blogurls);
Front-end calling code
Copy
<c:foreach items= "${blogurls}" var= "URLs" >
<a href= "${ctx}/blog/detail/${urls.id}.html" Urls-title ">${urls.title}</a><br>
</c:forEach>
jquery modifier Code
Copy
var objurltitles = $ (". Markdown"). Find (". Urls-title");
Objurltitles.each (function (e) {
if (0 = e) {
$ (this). Prepend ("<label> previous:</label>");
Else {
$ (this). Prepend ("<label> next:</label>");
}
);