显示所有用户页面
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ page import="com.news.dao.*,com.news.dao.impl.*,com.news.entity.*,com.news.util.*" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <link rel="stylesheet" type="text/css" href="css/css.css"> </head> <body> <table border="1" align="center"> <caption>=用户列表</caption> <tr> <td>编号</td> <td>账号</td> <td>密码</td> <td>邮箱</td> <td>住址</td> <td>爱好</td> </tr> <% //获取当前页码,如果获取不到,默认是第一页; String pageIndex=request.getParameter("pageIndex"); if(pageIndex==null){ pageIndex="1"; } int currentPage=Integer.parseInt(pageIndex); int pageSize=4; UserDao ud=new UserDaoImpl(); PageControler pc=new PageControler(); int count=ud.getCount(); //获得总页数; int totalPages=pc.getTotalPages(count,pageSize); //分页查询,得到当前页数数据; List<User>users=ud.queryUserByPage(currentPage,pageSize); for(int i=0;i<users.size();i++){ User user=users.get(i); %> <tr> <td><%=user.getId() %></td> <td><%=user.getUsername() %></td> <td><%=user.getPwd() %></td> <td><%=user.getEmail() %></td> <td><%=user.getAddress() %></td> <td><%=user.getHobby() %></td> </tr> <% } %> <!-- 分页控制 --> <tr class="altrow"> <td colspan="6"> 第<%=currentPage %>页/共<%=totalPages %>页 <a href='admin/show_user.jsp?pageIndex=<%=1 %>'>首页</a> <% if(currentPage>1){ %> <a href='admin/show_user.jsp?pageIndex=<%=currentPage-1 %>'>上一页||</a> <% } if(currentPage<totalPages){ %> <a href='admin/show_user.jsp?pageIndex=<%=currentPage+1 %>'>下一页</a>|| <%} %> <a href='admin/show_user.jsp?pageIndex=<%=totalPages %>'>末页</a> </td> </tr> </table> </body> </html>
显示所有新闻页面
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ page import="com.news.entity.*,com.news.dao.*,com.news.dao.impl.*" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'MyJsp.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <link rel="stylesheet" type="text/css" href="css/css.css"/> </head> <body> <table border="1" align="center"> <caption>新闻列表</caption> <tr> <td>编号</td> <td>标题</td> <td>作者</td> </tr> <% NewsDao td=new NewsDaoImpl(); List<News>newses=td.queryNews(); for(int i=0;i<newses.size();i++){ News news=newses.get(i); %> <tr> <td><%=news.getId() %></td> <td><%=news.getTitle() %></td> <td><%=news.getAuthor() %></td> </tr> <% } %> </table> </body> </html>
//显示所有主题页面
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ page import="com.news.entity.*,com.news.dao.*,com.news.dao.impl.*" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'showAllTopic.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <link rel="stylesheet" type="text/css" href="css/css.css"/> </head> <body> <table border="1" align="center"> <caption>主题列表</caption> <tr> <td>编号</td> <td>主题</td> <td>操作</td> </tr> <% TopicDao td=new TopicDaoImpl(); List<Topic>topices=td.getAllTopic(); for(int i=0;i<topices.size();i++){ Topic topic=topices.get(i); %> <tr> <td><%=topic.getId() %></td> <td><%=topic.getTname() %></td> <td> <a href="admin/updateTopic.jsp?id=<%=topic.getId() %>">修改</a>|| <a href="admin/deleteTopic_action.jsp?id=<%=topic.getId() %>" onclick="return confirm('确定删除?')">删除</a> </td> </tr> <% } %> </table> </body> </html>