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

Jsp/Servlet

开发平台:

Java

  1. <%@page contentType="text/html; charset=gb2312" language="java" %>
  2. <%@page import="com.mycompany.news.service.NewsService"%>
  3. <%@page import="com.mycompany.news.dao.impl.*"%>
  4. <%@page import="com.mycompany.news.dto.*"%>
  5. <%@page import="java.text.SimpleDateFormat"%>
  6. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  7. <html>
  8.  <head>
  9. <link href="./css/common.css" rel="stylesheet" type="text/css">
  10. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  11.    <title>新闻信息</title>
  12.  </head>
  13.  
  14. <%
  15. String pageNo=request.getParameter("pageNo");
  16. int commentPageNo=1;
  17. try{
  18. commentPageNo =Integer.parseInt(pageNo);
  19. }catch(Exception e){
  20. }
  21. Long id=Long.valueOf(request.getParameter("id"));
  22. SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
  23. NewsService service = new NewsService();
  24. com.mycompany.news.service.NewsCommentService commentService = new com.mycompany.news.service.NewsCommentService();
  25. service.setNewsDAO(new NewsDAOImpl());
  26. News news = service.getByID(id.longValue());
  27. java.util.List attachments = service.getAttachments(id.longValue());
  28. java.util.List pubComments = commentService.listPublicComment(news,commentPageNo,200);
  29. %>
  30. <body leftmargin="40" bgcolor="#FAFAFA">
  31. <table  align="center"  border=0 width="90%" height="80%" cellpadding=0 cellspacing=20 bgcolor=#EFEFEF>
  32. <TR>
  33.  <TD bgColor=#000000 height=1></TD>
  34. </TR>  
  35. <tr height="10%">
  36.  <td width="90%">
  37.   <table  width="100%" height="20%" background="./images/left1.gif">
  38.     <tr>
  39.      <td align="center">
  40.  <font size='4'>
  41.  <b><%=news.getSubject()%>(访问次数 <%=service .getVisitCount(id.longValue())%>)</b>
  42.  </font>
  43.      </td>
  44.    </tr>
  45.   <tr>
  46.      <td align="right" >
  47.      <font size='3'>
  48.      <b>作者(<%=news.getAuthor()%>)-- <%=sdf.format(news.getShowTime())%></b>
  49.      </font>
  50.      </td>
  51.   </tr>
  52.   </table>
  53. </tr>
  54. <TR>
  55.  <TD bgColor=#000000 height=1 width="60%"></TD>
  56. </TR>  
  57. <tr>
  58.  <td colspan='4' align="left" bgColor="#CCCCCC">
  59.          <%=news.getContent()%>
  60. </td>
  61.  </tr>
  62. <%for(int i=0;i<attachments.size();i++){
  63. NewsAttachment attachment = (NewsAttachment )attachments.get(i);
  64. if(service.isImage(attachment)){
  65. %>
  66. <tr>
  67.  <td align="right"><%=attachment.getAttachmentName()%>
  68.  <a href="<%=request.getContextPath()%>/servlet/download?id=<%=attachment.getAttachmentId()%>">
  69.  <image border="0" width="200" height="100" src="<%=request.getContextPath()%>/servlet/download?id=<%=attachment.getAttachmentId()%>">
  70.  </a>
  71.  </td>
  72.  
  73. </tr>
  74. <%
  75. }
  76. %>
  77. <%}%>
  78. <%for(int i=0;i<attachments.size();i++){
  79. NewsAttachment attachment = (NewsAttachment )attachments.get(i);
  80. if(!service.isImage(attachment)){
  81. %>
  82. <tr>
  83.  <td align="right"><a href="<%=request.getContextPath()%>/servlet/download?id=<%=attachment.getAttachmentId()%>">附件:<%=attachment.getAttachmentName()%></a></td>
  84. </tr>
  85. <%
  86. }
  87. %>
  88. <%}%>
  89. </table>
  90.  
  91.  <form action="<%=request.getContextPath()%>/servlet/addcomment">
  92.  <input type="hidden" name="newsId" value="<%=news.getNewsId() %>">
  93.  <table width="100%" height="10%">
  94.  <tr>
  95.   <td align="center"><b>评论</b></td>
  96.  </tr>
  97.   <tr>
  98.   <td align="center">
  99.   标题:<input type="text" name="commentSubject" size="120" value="评[<%=news.getSubject() %>]">
  100.   评论人:<input type="text" name="commentPerson" size="10">
  101.   </td>
  102.  </tr>
  103.  <tr>
  104.   <td align="center"><textarea name="commentContent" cols="150" rows="5"></textarea> </td>
  105.  </tr>
  106.  <tr>
  107.   <td align="right">
  108.   <input type="submit" name="b" value="添加">
  109.   <input type="reset" name="r" value="重置">
  110.   </td>
  111.  </tr>
  112.  </table>
  113.  </form>
  114.  
  115.  <table>
  116.   <%for(int i=0;i<pubComments.size();i++){ 
  117.   NewsComment comment = (NewsComment )pubComments.get(i);
  118.   %>
  119.   <tr>
  120.   <td width="80%" align="left"><%=comment.getCommentSubject() %></td>
  121.   <td width="20%" align="right"><%=comment.getCommentPerson() %></td>
  122.   </tr>
  123.   <tr>
  124.   <td>
  125.   <textarea cols="150" rows="5" readonly>
  126.   <%=comment.getCommentContent() %>
  127.   </textarea>
  128.   </td>
  129.   </tr>
  130.   <%} %>
  131.  </table>
  132. </body>
  133. </html>