newsmanage.jsp
上传用户:junmaots
上传日期:2022-07-09
资源大小:2450k
文件大小:3k
- <%@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" %>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gbk">
- <title>栏目新闻列表</title>
- <link href="../css/common.css" rel="stylesheet" type="text/css">
- </head>
-
- <%
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- String columnid = request.getParameter("columnid");
- ColumnService cs = new ColumnService();
- Column column = cs.getByID(Long.parseLong(columnid));
- int pageNo= 1;
- try{
- pageNo=Integer.parseInt(request.getParameter("pageNo"));
- }catch(Exception e){
- }
- int pageSize = 20;
- NewsService service = new NewsService();
- int totalCount = service.getNewsCountByColumn(Long.valueOf(columnid));
- List results = service.listNewsByColumn(Long.valueOf(columnid),pageNo,pageSize);
- int totalPage = totalCount/pageSize+(totalCount%pageSize==0?1:0);
- %>
- <body leftmargin="40">
- <br><br><br><br>
- <p>
- <a href="newsForm.jsp?columnid=<%=columnid%>">发布新闻</a>
- </p>
- <table align="left" border=0 width="95%" class="tbcolor">
- <tr class="titletab">
- <th width="15%">新闻时间</th>
- <th width="50%">新闻标题</th>
- <th width="10%">新闻作者</th>
- <th width="15%">操作</th>
- </tr>
- <%for(int i=0;i<results.size();i++){
- News news =(News)results.get(i);
- %>
- <tr>
- <td><%=sdf.format(news.getShowTime())%></td>
- <td><a href="../shownews.jsp?id=<%=news.getNewsId()%>" target="_blank"><%=news.getSubject()%></a></td>
- <td><%=news.getAuthor()%></td>
- <td>
- <a href="#" onclick="confirmdelete(<%=news.getNewsId() %>)">删除</a>
- <a href="newsmodify.jsp?id=<%=news.getNewsId()%>">编辑</a>
- <%if(news.isRecommended()){ %>
- <a href="<%=request.getContextPath()%>/servlet/cancelrecommendnews?newsid=<%=news.getNewsId()%>">取消推荐</a>
- <%}else{ %>
- <a href="<%=request.getContextPath()%>/servlet/recommendnews?newsid=<%=news.getNewsId()%>">推荐</a>
- <%} %>
- <a href="auditcomment.jsp?newsid=<%=news.getNewsId() %>">审核评论</a>
- </td>
- </tr>
- <%}%>
- </table>
-
- <table>
- <tr>
- <td colspan="3" align="right">
- <%if(pageNo>1){%>
- <a href="newslist.jsp?columnid=<%=columnid%>&pageNo=1">第一页</a>
- <a href="newslist.jsp?columnid=<%=columnid%>&pageNo=<%=pageNo-1%>">上一页</a>
- <%}%>
- <%if(pageNo<totalPage){%>
- <a href="newslist.jsp?columnid=<%=columnid%>&pageNo=<%=pageNo+1%>">下一页</a>
- <a href="newslist.jsp?columnid=<%=columnid%>&pageNo=<%=pageNo+1%>">最后页</a>
- <%}%>
- </td>
- </tr>
- </table>
- </body>
- <script language="javascript">
- function confirmdelete(newsid){
- if(confirm('确定要删除该新闻吗?')){
- location.replace('<%=request.getContextPath()%>/servlet/DeleteNews?newsid='+newsid);
- }
- }
- </script>
- </html>