recnews.jsp
上传用户:junmaots
上传日期:2022-07-09
资源大小:2450k
文件大小:2k
- <%@page contentType="text/html; charset=gbk" language="java" %>
- <%@page import="com.mycompany.news.service.*"%>
- <%@page import="com.mycompany.news.dto.*"%>
- <%@page import="java.util.List"%>
- <%@page import="java.text.SimpleDateFormat" %>
- <%@page import="java.util.List"%>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <link href="./css/common.css" rel="stylesheet" type="text/css">
- <meta http-equiv="Content-Type" content="text/html; charset=gbk">
- <title>推荐新闻列表</title>
- </head>
-
- <%
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- ChannelService channelService = new ChannelService();
- ColumnService columnService = new ColumnService();
- NewsService ns = new NewsService();
- String channelid= request.getParameter("channelid");
- System.out.println("channelid="+channelid);
- Channel channel = channelService.getByID(Integer.parseInt(channelid));
- int pageNo = 1;
- try{
- pageNo = Integer.parseInt(request.getParameter("pageNo"));
- }catch(Exception e){
- }
- int pageSize=50;
- NewsService service = new NewsService();
- List recNews = service.getRecommendedNews(Long.parseLong(channelid),pageNo,50);
- System.out.println("recNews ="+recNews);
- int totalCount= service.getRecommendedNewsCount(Long.parseLong(channelid));
- int totalPage = totalCount/pageSize+(totalCount%pageSize==0?1:0);
- %>
- <body leftmargin="40">
- <table width="90%" border=0 align="center" bgcolor="#CCCCCC" >
- <tr bgcolor="#FFFFFF">
- <th colspan='3'>《<%=channel.getChannelName()%>》推荐新闻</th>
- </tr>
- <tr bgcolor="#FFFFFF" >
- <th width="10%" height="23">新闻时间</th>
- <th width="50%" height="23">新闻标题</th>
- <th width="10%" height="23">新闻作者</th>
- </tr>
- <%for(int i=0;i<recNews.size();i++){
- News news =(News)recNews.get(i);
- %>
- <tr bgcolor="#FFFFFF">
- <td height="23"><%=news.getShowTime()%></td>
- <td height="23"><%=news.getSubject()%></td>
- <td height="23"><%=news.getAuthor()%></td>
- </tr>
- <%}%>
- </table>
-
- <table align="center">
- <tr>
- <td colspan="3" align="right">
- <%if(pageNo>1){%>
- <a href="rec_news.jsp?channelid=<%=channelid%>&pageNo=1">第一页</a>
- <a href="rec_news.jsp?channelid=<%=channelid%>&pageNo=<%=pageNo-1%>">上一页</a>
- <%}%>
- <%if(pageNo<totalPage){%>
- <a href="rec_news.jsp?channelid=<%=channelid%>&pageNo=<%=pageNo+1%>">下一页</a>
- <a href="rec_news.jsp?channelid=<channelid>&pageNo=<%=pageNo+1%>">最后页</a>
- <%}%>
- </td>
- </tr>
- </table>
- </body>
- </html>