recnews.jsp
上传用户:junmaots
上传日期:2022-07-09
资源大小:2450k
文件大小:2k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@page contentType="text/html; charset=gbk" language="java" %>
  2. <%@page import="com.mycompany.news.service.*"%>
  3. <%@page import="com.mycompany.news.dto.*"%>
  4. <%@page import="java.util.List"%>
  5. <%@page import="java.text.SimpleDateFormat" %>
  6. <%@page import="java.util.List"%>
  7. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  8. <html>
  9.  <head>
  10.  <link href="./css/common.css" rel="stylesheet" type="text/css">
  11. <meta http-equiv="Content-Type" content="text/html; charset=gbk">
  12.    <title>推荐新闻列表</title>
  13.  </head>
  14.  
  15. <%
  16. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  17. ChannelService channelService = new ChannelService();
  18. ColumnService columnService = new ColumnService();
  19. NewsService ns = new NewsService();
  20. String channelid= request.getParameter("channelid");
  21. System.out.println("channelid="+channelid);
  22. Channel channel = channelService.getByID(Integer.parseInt(channelid));
  23. int pageNo = 1;
  24. try{
  25. pageNo = Integer.parseInt(request.getParameter("pageNo"));
  26. }catch(Exception e){
  27. }
  28. int pageSize=50;
  29. NewsService service = new NewsService();
  30. List recNews = service.getRecommendedNews(Long.parseLong(channelid),pageNo,50);
  31. System.out.println("recNews ="+recNews);
  32. int  totalCount= service.getRecommendedNewsCount(Long.parseLong(channelid));
  33. int totalPage = totalCount/pageSize+(totalCount%pageSize==0?1:0);
  34. %>
  35. <body leftmargin="40">
  36. <table width="90%"  border=0  align="center" bgcolor="#CCCCCC" >
  37. <tr bgcolor="#FFFFFF">
  38. <th colspan='3'>《<%=channel.getChannelName()%>》推荐新闻</th>
  39. </tr>
  40. <tr bgcolor="#FFFFFF" >
  41. <th width="10%" height="23">新闻时间</th>
  42. <th width="50%" height="23">新闻标题</th>
  43. <th width="10%" height="23">新闻作者</th>
  44. </tr>
  45. <%for(int i=0;i<recNews.size();i++){
  46. News news  =(News)recNews.get(i);
  47. %>
  48. <tr bgcolor="#FFFFFF">
  49. <td height="23"><%=news.getShowTime()%></td>
  50. <td height="23"><%=news.getSubject()%></td>
  51. <td height="23"><%=news.getAuthor()%></td>
  52. </tr>
  53. <%}%>
  54. </table>
  55.  
  56. <table align="center">
  57. <tr>
  58. <td colspan="3" align="right">
  59. <%if(pageNo>1){%>
  60. <a href="rec_news.jsp?channelid=<%=channelid%>&pageNo=1">第一页</a>
  61. <a href="rec_news.jsp?channelid=<%=channelid%>&pageNo=<%=pageNo-1%>">上一页</a>
  62. <%}%>
  63. <%if(pageNo<totalPage){%>
  64. <a href="rec_news.jsp?channelid=<%=channelid%>&pageNo=<%=pageNo+1%>">下一页</a>
  65. <a href="rec_news.jsp?channelid=<channelid>&pageNo=<%=pageNo+1%>">最后页</a>
  66. <%}%>
  67. </td>
  68. </tr>
  69. </table>
  70. </body>
  71. </html>