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

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. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  7. <html>
  8.  <head>
  9. <meta http-equiv="Content-Type" content="text/html; charset=gbk">
  10.    <title>栏目新闻列表</title>
  11. <link href="../css/common.css" rel="stylesheet" type="text/css">
  12.  </head>
  13.  
  14. <%
  15. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  16. String columnid = request.getParameter("columnid");
  17. ColumnService cs = new ColumnService();
  18. Column column = cs.getByID(Long.parseLong(columnid));
  19. int pageNo= 1;
  20. try{
  21. pageNo=Integer.parseInt(request.getParameter("pageNo"));
  22. }catch(Exception e){
  23. }
  24. int pageSize = 20;
  25. NewsService service = new NewsService();
  26. int totalCount = service.getNewsCountByColumn(Long.valueOf(columnid));
  27. List results = service.listNewsByColumn(Long.valueOf(columnid),pageNo,pageSize);
  28. int totalPage = totalCount/pageSize+(totalCount%pageSize==0?1:0);
  29. %>
  30. <body leftmargin="40">
  31. <br><br><br><br>
  32. <p>
  33. <a href="newsForm.jsp?columnid=<%=columnid%>">发布新闻</a>
  34. </p>
  35. <table  align="left"  border=0 width="95%" class="tbcolor">
  36. <tr class="titletab">
  37. <th width="15%">新闻时间</th>
  38. <th width="50%">新闻标题</th>
  39. <th width="10%">新闻作者</th>
  40. <th width="15%">操作</th>
  41. </tr>
  42. <%for(int i=0;i<results.size();i++){
  43. News news  =(News)results.get(i);
  44. %>
  45. <tr>
  46. <td><%=sdf.format(news.getShowTime())%></td>
  47. <td><a href="../shownews.jsp?id=<%=news.getNewsId()%>" target="_blank"><%=news.getSubject()%></a></td>
  48. <td><%=news.getAuthor()%></td>
  49. <td>
  50. <a href="#" onclick="confirmdelete(<%=news.getNewsId() %>)">删除</a>
  51. <a href="newsmodify.jsp?id=<%=news.getNewsId()%>">编辑</a>
  52. <%if(news.isRecommended()){ %>
  53. <a href="<%=request.getContextPath()%>/servlet/cancelrecommendnews?newsid=<%=news.getNewsId()%>">取消推荐</a>
  54. <%}else{ %>
  55. <a href="<%=request.getContextPath()%>/servlet/recommendnews?newsid=<%=news.getNewsId()%>">推荐</a>
  56. <%} %>
  57. <a href="auditcomment.jsp?newsid=<%=news.getNewsId() %>">审核评论</a>
  58. </td>
  59. </tr>
  60. <%}%>
  61. </table>
  62.  
  63. <table>
  64. <tr>
  65. <td colspan="3" align="right">
  66. <%if(pageNo>1){%>
  67. <a href="newslist.jsp?columnid=<%=columnid%>&pageNo=1">第一页</a>
  68. <a href="newslist.jsp?columnid=<%=columnid%>&pageNo=<%=pageNo-1%>">上一页</a>
  69. <%}%>
  70. <%if(pageNo<totalPage){%>
  71. <a href="newslist.jsp?columnid=<%=columnid%>&pageNo=<%=pageNo+1%>">下一页</a>
  72. <a href="newslist.jsp?columnid=<%=columnid%>&pageNo=<%=pageNo+1%>">最后页</a>
  73. <%}%>
  74. </td>
  75. </tr>
  76. </table>
  77. </body>
  78. <script language="javascript">
  79. function confirmdelete(newsid){
  80.   if(confirm('确定要删除该新闻吗?')){
  81.    location.replace('<%=request.getContextPath()%>/servlet/DeleteNews?newsid='+newsid);
  82.   }
  83. }
  84. </script>
  85. </html>