Using Java to implement the article content on a next function __java

Source: Internet
Author: User

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>"); } );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.