JSP新闻系统之三后台显示页面

举报
tea_year 发表于 2021/12/29 23:45:06 2021/12/29
【摘要】 显示所有用户页面 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ page import="com.news.dao.*,com.news.dao.impl.*,com.news.entity.*,com.news.uti...
显示所有用户页面
<%@ 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() %>" οnclick="return confirm('确定删除?')">删除</a>
    		</td>
    	</tr>
    	<% 
    		}
    	%>
    </table>
  </body>
</html>


文章来源: aaaedu.blog.csdn.net,作者:tea_year,版权归原作者所有,如需转载,请联系作者。

原文链接:aaaedu.blog.csdn.net/article/details/53044469

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。