博客系统详情页实现上一篇、下一篇

其实很简单,只要获取当前文章id,通过order by,limit就可以实现,话不多说,上代码!!

sql:

      下一篇(id>5): select  id,title  where   id>  5 order by id asc limit 1;

      上一篇(id<5): select  id,title  where   id <  5  order by  id desc  limit 1 ;

jsp页面(通过ajax传入当前文章id,status等)

id从controller获得

下一篇方法同上

controller代码(如果有多个参数可以使用Map接参)

serviceImp代码

猜你喜欢

转载自blog.csdn.net/weixin_42452645/article/details/83958401