<%@page import="bdqn.newsManageServlet.Util.PageUitl"%> <%@page import="bdqn.newsManageServlet.Service.Impl.newsTbServiceImpl"%> <%@page import="bdqn.newsManageServlet.Service.newsTbService"%> <%@page import="bdqn.newsManageServlet.Dao.Impl.newsTbDaoImpl"%> <%@page import="bdqn.newsManageServlet.Dao.newsTbDao"%> <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ page language="java" import="bdqn.newsManageServlet.Dao.BaseDao" %> <%@ page language="java" import="bdqn.newsManageServlet.Dao.newsTbDao" %> <%@ page language="java" import="bdqn.newsManageServlet.entity.newsTb" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>后台界面</title> <link href="../CSS/admin.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="../js/jquery-1.8.3.js"></script> <script type="text/javascript"> function clickdel(){ if(confirm("是否要删除该条新闻?")==true){ return true; }else{ return false; } } </script> </head> <body> <ul class="classlist"> <% //newsTbDao newdao=new newsTbDaoImpl(); newsTbService newsService=new newsTbServiceImpl(); //获取总记录数 int recordCount=newsService.getNewsCount(); int pagesize=5; int pageindex=1;//默认是第一页 //获取当前页的传值 String curPage = request.getParameter("curPage"); //第一次访问该页面没有传值,所以为null if (curPage == null) { pageindex = 1; } else { pageindex = Integer.parseInt(curPage); } PageUitl pageutil = new PageUitl(); pageutil.setPagesize(pagesize); pageutil.setRecordCount(recordCount); //获取总页数 int pageCount = pageutil.getTotalPageCount(); // if(pageindex<1){ pageindex=1; }else if(pageindex>pageCount){ pageindex=pageCount; } pageutil.setPageindex(pageindex); //获取当前页新闻 List<newsTb> newsList = newsService.getPagingNews(pagesize, pageindex); for (int i = 0; i < newsList.size(); i++) { newsTb news = newsList.get(i);//获取每条新闻 %> <li><a href="readNews.jsp?newsid=<%=news.getNewsID() %>"> <%=news.getTitle() %></a> <span> 作者: <%=news.getAuthor() %> <a href='modifyNews.jsp?newsid=<%=news.getNewsID() %>'>修改</a> <a href='../doDelNewsServlet?newsid=<%=news.getNewsID() %>' onclick='return clickdel()'>删除</a> </span></li> <!-- 满足条件的话显示空行 --> <%if((i+1)%5==0){ %> <li class='space'></li> <%} %> <% } %> <p align="right"> 当前页数:[<%= pageindex%>/<%=pageCount %>] <%if(pageindex>1){ %> <a href="newsPage.jsp?curPage=1">首页</a> <a href="newsPage.jsp?curPage=<%=pageindex-1 %>">上一页</a> <%} %> <%if(pageindex<pageCount){ %> <a href="newsPage.jsp?curPage=<%=pageindex+1 %>">下一页</a> <a href="newsPage.jsp?curPage=<%=pageCount %>">末页</a> <%} %> </p> </ul> </body> </html>