这个就和点击链接是一个道理的 我写过是实现点击链接的,我想道理是一样的上一篇,下一篇,点击相应的链接就转到新的文章,这个其实也不太难,我用的是个笨方法,仅供参考: 思路是得到当前的信息时就得到下一篇的信息;===========action中==========public ActionForward toViewDiary(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { String dId=request.getParameter("diaryId"); String UId=request.getParameter("userId"); //被访问人的Id Account comUser=null; if(UId!=null) { int id=Integer.parseInt(UId); comUser=this.accountBiz.GetUserById(id); //被访问人的信息 }else { } String page=request.getParameter("page"); //分页(我这用到了,你们没用的话就不用写) if(page==null) { page="1"; } pageInfo.setPageIndex(Integer.parseInt(page)); pageInfo.setPageSize(1); try { Account account=(Account)request.getSession().getAttribute("user"); int clickNum=0; //点击数 if(account!=null) { //根据ID得到日志信息 Diary diary=this.diaryBiz.getDiaryById(Integer.parseInt(dId)); //得到所有的日志信息 List diaryList=this.diaryBiz.GetDiaryListByUserId(comUser.getId(), null); if(account.getId().equals(comUser.getId())) { clickNum=diary.getCheckNum(); //得到当前点击数 }else { clickNum=diary.getCheckNum(); //得到当前点击数 clickNum++; //点击数+1 diary.setCheckNum(clickNum); this.diaryBiz.updateDiary(diary); //更新日志信息 } //根据Id得到此日志的所有回复 pageInfo.setPageSize(5); List rdiaryList=this.rdiaryBiz.getRRiaryById(Integer.parseInt(dId), pageInfo);(第二个参数是分页的信息,请参考ssh分页文章) request.setAttribute("rdiaryList", rdiaryList); request.setAttribute("diary", diary); request.setAttribute("diaryList", diaryList); request.setAttribute("comUser", comUser); }else { response.sendRedirect("/hiWithMe/init.do?method=doInit"); return null; } }catch(Exception ex) { } return mapping.findForward("detal");}=============页面中用到小脚本====================<%Account comUser=(Account)request.getAttribute("comUser"); //存放被访问人的信息Account account=(Account)request.getSession().getAttribute("user"); //当前登录用户List diaryList=(List)request.getAttribute("diaryList"); //得到所有的文章信息Diary diaryNow=(Diary)request.getAttribute("diary"); //得到当前显示的文章String msg="";Diary diaryUp=new Diary(); //上一篇文章信息Diary diaryDown=new Diary(); //下一篇文章信息int downId=0;if(diaryList!=null) {for(int i=0;i<diaryList.size();i++) { Diary diaryInfo=(Diary)diaryList.get(i); if(diaryInfo.getId().equals(diaryNow.getId())) { if(i-1<0) { //判断是否是第一篇 msg="当前就是第一篇"; diaryUp=diaryNow; }else { diaryUp=(Diary)diaryList.get(i-1); //不是的话就得到上一篇的信息 } if(i+1>=diaryList.size()) { msg="当前就是最后一篇"; diaryDown=diaryNow; }else{ downId=i+1; System.out.println(downId+"================================="); //理由同上 diaryDown=(Diary)diaryList.get(downId); } }}}else {}%><a href="<%=basePath %>blog.do?method=toViewDiary&diaryId=<%=diaryUp.getId() %>&userId=<%=comUser.getId() %>" class="more" onclick="return checkDiary(<%=diaryUp %>,<%=msg %>);">上一篇</a> - <a href="<%=basePath %>blog.do?method=toViewDiary&diaryId=<%=diaryDown.getId() %>&userId=<%=comUser.getId() %>" class="more" onclick="checkDiary(<%=diaryDown %>,<%=msg %>);">下一篇</a>