<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="GB2312"%>
<%@ page import="java.util.Collection,java.util.Iterator"%>
<%@ page import="com.wxpn.tutorial.servlet.News"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>浏览</title>
</head>
<body>
<center>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
	<tr>
		<td width="75%" bgcolor="#0000FF" height="35" align=center><b><font
			color="#FFFFFF">浏览新闻 </font></b></td>
	</tr>
</table>
<table border="1" width="100%" bordercolorlight="#C0C0C0"
	bordercolordark="#FFFFFF" cellspacing="0" cellpadding="0">
	<tr>
		<td width="10%" bgcolor="#FCFCFC">编号</td>
		<td width="60%" bgcolor="#FCFCFC">题目</td>
		<td width="15%" bgcolor="#FCFCFC">发布日期</td>
		<td width="15%" bgcolor="#FCFCFC">发布人</td>
	</tr>
	<%if (request.getAttribute("c") == null) {

			%>
	<tr>
		<td width="" 75%"" colspan=5 bgcolor="#FCFCFC" align=center>还没有任何新闻。</td>
	</tr>
	<%} else {
				Collection c = (Collection) request.getAttribute("c");
				if (c == null) {

				%>
	<tr>
		<td width="" 75%"" colspan=5 bgcolor="#FCFCFC" align=center>还没有任何新闻。</td>
	</tr>
	<%} else {
					int totalPageNum = ((Integer) (request
							.getAttribute("totalPageNum"))).intValue();
					int currentPage = 1;
					if (request.getParameter("page") != null) {
						currentPage = Integer.parseInt(request
								.getParameter("page"));
					}
					Iterator iterator = c.iterator();
					while (iterator.hasNext()) {
						News msg = (News) iterator.next();

						%>
	<tr>
		<td width="10%" bgcolor="#FCFCFC"><a
			href="ReadServlet?id=<%=msg.getId()%>"><%=msg.getId()%></a></td>
		<td width="60%" bgcolor="#FCFCFC"><%=msg.getTitle()%></td>
		<td width="15%" bgcolor="#FCFCFC"><%=msg.getStrCompose_date()%></td>
		<td width="15%" bgcolor="#FCFCFC"><%=msg.getAuthor()%></td>
	</tr>
	<%}%>
	<tr>
		<td width="75%" colspan=5 align=right height="50" bgcolor="#EFEFEF"><%for (int i = 1; i <= totalPageNum; i++) {%>
		<a href="BrowseServlet?page=<%=i %>">[<%=i%>]</a> <%}

				%>
	</tr>
	<%}
			}

			%>
	<tr>
		<td width="75%" colspan=5 align=center height="50" bgcolor="#EFEFEF">
		<%//如果用户已经登录，则允许发布留言：
			if (session.getAttribute("userName") != null) {%> [<a
			href="compose.jsp">发布新闻</a>] <%} else {

			%>[<a href="login.jsp">登录</a>] <%}%>
	</tr>
</table>
</center>
</body>
</html>
