📄 bbsview.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="../error/error.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>社区论坛</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<link rel="stylesheet" type="text/css" href="../image/com.css"/>
<script language="JavaScript" src="../image/com.js"></script>
<body>
<div align="center">
<center>
<table width="746" height="87" border="1" bordercolor="#ffffff" bordercolordark="#ffffff" bordercolorlight="#0066ff" cellspacing="0" cellpadding="-1">
<tr align="center" bgcolor="#CCCCFF">
<td height="22" colspan="4" ><a href="bbs.jsp" class="style10">发表新贴</a></td>
</tr>
<tr>
<td width="488" height="22" align="center">主题</td>
<td width="35" height="22" align="center">回复</td>
<td width="35" height="22" align="center">人气</td>
<td width="183" height="22" align="center">最新回复</td>
</tr>
<%
String sqli=" SELECT * FROM bbs ORDER BY 主题id DESC";
Connection con=useBean.Link_db.getCon();
Statement state=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs=state.executeQuery(sqli);
String color="";
//countpage总页数,sqan宽度,count总纪录数,fpage现在页,fcount现纪录数
String strpages=(String)request.getParameter("pages");
int pages=0;
if(strpages==null){
pages=0;
}else{
pages=Integer.parseInt(strpages);
}
rs.last();
int sqan=18,i=0,fcount=0;
int count=rs.getRow();
int countpage=count/sqan;
if(count%sqan>0) countpage=countpage+1;
if(pages<0) pages=0;
if(pages>countpage-1) pages=countpage-1;
fcount=pages*sqan+1;
int fpage=(count-fcount)/sqan+1;
rs.absolute(fcount);
rs.previous();
while(rs.next()){
int id=rs.getInt("主题id");
String title=rs.getString("主题");
int re=rs.getInt("回复");
int po=rs.getInt("人气");
String totime=rs.getString("发表时间");
String retime=rs.getString("最后回复");
if(retime==null) retime=totime;
if(color==""){
color="#FFFFff";
}else{
color="";
}
%>
<tr bgcolor=<%=color%>>
<td width="488" height="22" align="center"> <a href="rebbsview.jsp?id=<%=id%>"><%=title%></a></td>
<td width="35" height="22" align="center"><%=re%></td>
<td width="35" height="22" align="center"><%=po%></td>
<td width="183" height="22" align="center"><%=retime%></td>
</tr>
<%
i++;if(i==sqan) break;
}
try{
con.close();
}catch(Exception e){
}
%>
<tr align="right" bgcolor="#CCCCFF">
<td height="22" colspan="5">第<%=(pages+1)%>/<%=countpage%>页 <a href="bbsview.jsp?pages=<%=(pages-1)%>">上一页</a> <a href="bbsview.jsp?pages=<%=(pages+1)%>">下一页</a></td>
</tr>
</table>
</center>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -