<%@page import="bdqn.newsManageServlet.Util.PageUitl"%>
<%@page import="bdqn.newsManageServlet.Service.Impl.commentServiceImpl"%>
<%@page import="bdqn.newsManageServlet.Service.commentService"%>
<%@page import="bdqn.newsManageServlet.entity.comment"%>
<%@page import="bdqn.newsManageServlet.Dao.Impl.commentDaoImpl"%>
<%@page import="bdqn.newsManageServlet.Dao.commentDao"%>
<%@page import="bdqn.newsManageServlet.Dao.Impl.categoryTBDaoImpl"%>
<%@page import="bdqn.newsManageServlet.entity.categoryTB"%>
<%@page import="bdqn.newsManageServlet.Dao.categoryTBDao"%>
<%@page import="bdqn.newsManageServlet.entity.newsTb"%>
<%@page import="bdqn.newsManageServlet.Dao.Impl.newsTbDaoImpl"%>
<%@page import="bdqn.newsManageServlet.Dao.newsTbDao"%>
<%@page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<title>新闻中国</title>
<link href="../CSS/read.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function check(){
var cauthor = document.getElementById("cauthor");
var content = document.getElementById("ccontent");
if(cauthor.value == ""){
alert("用户名不能为空!!");
return false;
}else if(content.value == ""){
alert("评论内容不能为空!!");
return false;
}
return true;
}
</script>
</head>
<body>
<div id="header">
<div id="top_login">
<label> 登录名 </label>
<input type="text" id="uname" value="" class="login_input" />
<label> 密码 </label>
<input type="password" id="upwd" value="" class="login_input" />
<input type="button" class="login_sub" value="登录" οnclick="login()"/>
<label id="error"> </label>
<a href="../index.jsp" class="login_link">返回首页</a> <img src="../Images/friend_logo.gif" alt="Google" id="friend_logo" /> </div>
<div id="nav">
<div id="logo"> <img src="../Images/logo.jpg" alt="新闻中国" /> </div>
<div id="a_b01"> <img src="../Images/a_b01.gif" alt="" /> </div>
<!--mainnav end-->
</div>
</div>
<div id="container">
<div class="sidebar">
<h1> <img src="../Images/title_1.gif" alt="国内新闻" /> </h1>
<div class="side_list">
<ul>
<%
//先类别名查询id
categoryTBDao cgdao=new categoryTBDaoImpl();
categoryTB cate=cgdao.getCateByName("国内");
int id=cate.getCategoryID();
//根据类别id在新闻表里面查询新闻信息
newsTbDao ndao=new newsTbDaoImpl();
List<newsTb>newlist=ndao.getnewsAllById(id);
for(int i=0;i<newlist.size();i++){
newsTb news0=newlist.get(i);
%>
<li> <a href='news_read.jsp?newsid=<%=news0.getNewsID() %>'><b><%=news0.getTitle()%></b></a> </li>
<% }%>
</ul>
</div>
<h1> <img src="../Images/title_2.gif" alt="国际新闻" /> </h1>
<div class="side_list">
<ul>
<%
//先类别名查询id
categoryTBDao cgdao1=new categoryTBDaoImpl();
categoryTB cate1=cgdao1.getCateByName("国外");
int id1=cate1.getCategoryID();
//根据类别id在新闻表里面查询新闻信息
newsTbDao ndao1=new newsTbDaoImpl();
List<newsTb>newlist1=ndao1.getnewsAllById(id1);
for(int i=0;i<newlist1.size();i++){
%>
<li> <a href='news_read.jsp?newsid=<%=newlist1.get(i).getNewsID() %>'><b><%=newlist1.get(i).getTitle()%> </b></a> </li>
<%} %>
</ul>
</div>
<h1> <img src="../Images/title_3.gif" alt="娱乐新闻" /> </h1>
<div class="side_list">
<ul>
<%
//先类别名查询id
categoryTBDao cgdao2=new categoryTBDaoImpl();
categoryTB cate2=cgdao2.getCateByName("娱乐");
int id2=cate2.getCategoryID();
//根据类别id在新闻表里面查询新闻信息
newsTbDao ndao2=new newsTbDaoImpl();
List<newsTb>newlist2=ndao2.getnewsAllById(id2);
for(int i=0;i<newlist2.size();i++){
%>
<li> <a href='news_read.jsp?newsid=<%=newlist2.get(i).getNewsID() %>'><b> <%=newlist2.get(i).getTitle()%></b></a> </li>
<%} %>
</ul>
</div>
</div>
<%
//获取新闻内容
int nid=Integer.parseInt(request.getParameter("newsid"));
newsTbDao ndao11=new newsTbDaoImpl();
newsTb news=ndao11.getAllNewsById(nid);
%>
<div class="main">
<div class="class_type"> <img src="../Images/class_type.gif" alt="新闻中心" /> </div>
<div class="content">
<ul class="classlist">
<table width="80%" align="center">
<tr width="100%">
<td colspan="2" align="center"><%=news.getTitle() %></td>
</tr>
<tr>
<td colspan="2"><hr />
</td>
</tr>
<tr>
<td align="center"><%=news.getCreateDate() %></td>
<td align="left">sport </td>
</tr>
<tr>
<td colspan="2" align="center"><%=news.getAuthor() %></td>
</tr>
<tr>
<td colspan="2">
<%=news.getContent() %></td>
</tr>
<tr>
<td colspan="2"><hr />
</td>
</tr>
</table>
</ul>
<ul class="classlist">
<table width="80%" align="center">
<%
//根据新闻的id查询评论信息
// commentDao comdao=new commentDaoImpl();
//List<comment> clist=comdao.getCommentAllByNewsid(nid);
commentService commService=new commentServiceImpl();
//页大小
int pagesize=3;
//页码
int pageindex=1;
//获取总记录数
int recordCount=commService.getPageCount(nid);
String curpage=request.getParameter("curpage");
if(curpage==null){
pageindex=1;
}else{
pageindex=Integer.parseInt(curpage);
}
//计算总页数
PageUitl pageutil=new PageUitl();
pageutil.setPagesize(pagesize);
pageutil.setRecordCount(recordCount);
int pageCount=pageutil.getTotalPageCount();
if(pageindex<1){
pageindex=1;
}else if(pageindex>pageCount){
pageindex=pageCount;
}
pageutil.setPageindex(pageindex);
List<comment> clist=commService.getCommentPage(pagesize, pageindex, nid);
%>
<td colspan="6">
<%
for(int i=0;i<clist.size();i++){
%>
<%=(i+1)%>.<%=clist.get(i).getCmmContent()%> <br/><br/>
<% }%>
</td>
<tr><td style=" 400px"></td>
<td>
当前页[<%=pageindex %>/<%=pageCount %>]
<% if(pageindex>1){%>
<a href="news_read.jsp?curpage=1&newsid=<%=nid%>">首页</a>
<a href="news_read.jsp?curpage=<%=pageindex-1%>&newsid=<%=nid%>">上一页</a>
<%} %>
<%if(pageindex<pageCount){ %>
<a href="news_read.jsp?curpage=<%=pageindex+1%>&newsid=<%=nid%>">下一页</a>
<a href="news_read.jsp?curpage=<%=pageCount%>&newsid=<%=nid%>">末页</a>
<%} %>
</td>
</tr>
<tr>
<td colspan="6"><hr/>
</td>
</tr>
</table>
</ul>
<ul class="classlist">
<form action="doNews_readServlet" method="post" οnsubmit="return check()">
<table width="80%" align="center">
<tr>
<td> 评 论 </td>
</tr>
<tr>
<td> 用户名: </td>
<tr>
<td><input type="hidden" name="newsid" value="<%=news.getNewsID()%>"/></td>
</tr>
<td><input id="cauthor" name="cauthor" value="这家伙很懒什么也没留下"/>
IP:
<input name="cip" value="127.0.0.1"
readonly="readonly"/>
</td>
</tr>
<tr>
<td colspan="2"><textarea name="ccontent" cols="70" rows="10"></textarea>
</td>
</tr>
<td><input name="submit" value="发 表" type="submit"/>
</td>
</table>
</form>
</ul>
</div>
</div>
</div>
<div id="friend">
<h1 class="friend_t"> <img src="../Images/friend_ico.gif" alt="合作伙伴" /> </h1>
<div class="friend_list">
<ul>
<li> <a href="#">中国政府网</a> </li>
<li> <a href="#">中国政府网</a> </li>
<li> <a href="#">中国政府网</a> </li>
<li> <a href="#">中国政府网</a> </li>
<li> <a href="#">中国政府网</a> </li>
<li> <a href="#">中国政府网</a> </li>
<li> <a href="#">中国政府网</a> </li>
</ul>
</div>
</div>
<div id="footer">
<p class=""> 24小时客户服务热线:010-68988888 <a href="#">常见问题解答</a> 新闻热线:010-627488888 <br />
文明办网文明上网举报电话:010-627488888 举报邮箱: <a href="#">jubao@jb-aptech.com.cn</a> </p>
<p class="copyright"> Copyright © 1999-2009 News China gov, All Right Reserver <br />
新闻中国 版权所有 </p>
</div>
</body>
</html>