<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.Collection,java.util.Iterator"%>
<%@ page import="com.wxpn.tutorial.servlet.BBSMsg"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>BBS-浏览</title>
<style type="">
.t1 {
	FONT-SIZE: 10.5pt; WORD-BREAK: break-all; BORDER-COLLAPSE: collapse; TEXT-ALIGN: justify
}
</style>
</head>

<body>
<center>
<table width="100%">
	<tr>
		<td width="100%" bgcolor="#0000FF" height="35" align=center><b><font
			color="#FFFFFF">浏览留言</font></b></td>
	</tr>
</table>
<table width="100%" class="t1">
	<%if (request.getAttribute("c") == null) {

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

				%>
	<tr>
		<td width="75%" colspan=8 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();
%>
	<tr>
		<td width="75%" colspan=8 align=right height="20" bgcolor="#EFEFEF"><%if (totalPageNum > 1) {%>
		<a href="BrowseServlet?page=1">首页</a>|<a
			href="BrowseServlet?page=<%=currentPage>1?currentPage-1:1 %>">上一页</a>|<a
			href="BrowseServlet?page=<%=currentPage<totalPageNum?currentPage+1:totalPageNum %>">下一页</a>|<a
			href="BrowseServlet?page=<%=totalPageNum%>">末页</a> <%}%>
	</tr>
<%
						while (iterator.hasNext()) {
						BBSMsg msg = (BBSMsg) iterator.next();

						%>
	<tr>
		<td width="100%">
		<hr size=1 color=#99ccff>
		<%for (int i = 0; i < msg.getLevel(); i++) {%> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <%}%>
		<a href="ReadServlet?id=<%=msg.getItem_id()%>">
		<img src="/BBS/image/<%=msg.getFace()%>.gif" border="0"><font
			color=#000000><%=msg.getItem_title()%></font>-&nbsp;<%=msg.getAuthor()%>&nbsp;<%=msg.getStrCompose_date()%>(<%=msg.getBrowsed_times()%>次点击)
			<%if((msg.getIs_origional()==1)&&(msg.getLatest_replyer()!=null)&&(!msg.getLatest_replyer().equals(""))){%>
			[最新回复:<%=msg.getLatest_replyer()%>&nbsp;<%=msg.getStrLatest_reply_date()%>]<%}%>
			</td>
	</tr>
	<%}%>

	<form name="form1" method="get">
			<tr>
				<td width="" colspan=5 align=right bgcolor="#EFEFEF"><%for (int i = 1; i <= totalPageNum; i++) {%>
				<a href="BrowseServlet?page=<%=i %>">[<%=i%>]</a> <%}

					%>共[<%=totalPageNum%>]页 <input type="text"
					size="2" name="page" value=""><input type="submit" name="go"
					value="Go"></td>
			</tr>
			</form>
	<%}
			}

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

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