main.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.dao.impl.*"%>
- <%@page import="com.mycompany.news.dto.*"%>
- <%@page import="java.text.SimpleDateFormat" %>
- <%@page import="java.util.*"%>
- <%
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- ChannelService channelService = new ChannelService();
- ColumnService columnService = new ColumnService();
- NewsService ns = new NewsService();
- List allChannels = channelService.listAllChannels();
- if(allChannels==null)
- allChannels=new ArrayList();
- %>
- <!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>
-
- <body leftmargin="40">
- <%for(int i=0;i<allChannels.size();i++){
- Channel channel = (Channel)allChannels.get(i);
- List recNews = ns.getRecommendedNews(channel.getChannelID().longValue(),1,5);
- if(recNews.size()==0)continue;
- %>
- <table align='center'>
- <tr>
- <td align="center" width="100%" colspan="3">
- <font color='#CCCCFF'><b><%=channel.getChannelName()%></b></font>
- </td>
- </tr>
- <%
-
- for(int j=0;j<recNews.size();j++){
- News news = (News)recNews.get(j);
- %>
- <tr>
- <td width="10%"><%=sdf.format(news.getShowTime())%></td>
- <td width="70%"><a href="shownews.jsp?id=<%=news.getNewsId()%>" target="_blank"><%=news.getSubject()%></a></td>
- <td width="20%"><%=news.getAuthor()%></td>
- </tr>
- <%}
- %>
- </table>
- <%}%>
- </body>