📄 manage.jsp
字号:
<% String getLoginmessage = (String) session.getValue("loginSign");
if(getLoginmessage!="admin"){
%>
<script language=javascript>
window.location="../false.jsp"
</script>
<% }
%>
<html>
<head>
<%@ page contentType="text/html;charset=gb2312"%>
<title>论坛管理</title>
<link rel=stylesheet href="../style.css" type="text/css">
<script language="JavaScript">
function newwin(url) {
var newwin=window.open(url,"newwin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=450");
newwin.focus();
return false;
}
</script>
</head>
<body>
<script LANGUAGE="javascript">
function submit11()
{
self.location.replace("manage.jsp")
}
</script>
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="bbsBean" scope="page" class="firm.firm" />
<%
int pageLine=10;
int totalRec=0;
int totalSub=0;
int intPage=1;
if (request.getParameter("page")!=null)
intPage=Integer.parseInt(request.getParameter("page"));
try{
ResultSet countrs=null;
//指定参考行数
//取得总数
countrs=bbsBean.executeQuery("select count(*) as cnt from board");
if (countrs.next())
totalRec=countrs.getInt("cnt");
countrs.close();
bbsBean.closeStmt();
//取得主题数
countrs=bbsBean.executeQuery("select count(*) as cnt from board");
if (countrs.next())
totalSub=countrs.getInt("cnt");
countrs.close();
bbsBean.closeStmt();
}
catch(Exception e){
e.printStackTrace();
}
//取得每行的主题数量
int jtemp=totalRec/pageLine+1;
int totalSubPerPage=totalSub/jtemp;
//取得总页数
int intPageCount=0;
intPageCount=(totalSub/totalSubPerPage * 10 + 5)/10 ;
%>
<center><font color="blue"><h4>论坛管理</h4></font>
<%
out.print("<table border='1' cellspacing='0' width='632' bgcolor='#d7e3b9' bordercolorlight='#green' bordercolordark='#ECF5FF'>");
out.print("<tr align='center' bgcolor='#c8cc98'>");
out.print("<td width='240'>标题</td>");
out.print("<td width='60'>发表人</td>");
out.print("<td width='100'>发表时间</td>");
out.print("<td width='40'>回复数</td>");
out.print("<td width='40'>点击数</td>");
out.print("<td width='40'>管理</td>");
out.print("<td width='40'>精华区</td>");
out.print("</tr>");
%>
<%
String serial;
String title;
String speaker;
Date providedate;
int reply;
int click;
ResultSet RS=bbsBean.executeQuery("select * from board where parent_no=0 order by serial_no DESC");
int i=0;
while (RS.next()) {
i++;//-----------------显示本级的帖子内容
if (i>(totalSubPerPage *(intPage-1)) && (i<=(intPage * totalSubPerPage))){
out.print("<tr><td>");
serial=RS.getString("serial_no");
title=RS.getString("title");
speaker=RS.getString("speaker");
providedate=RS.getDate("provide_time");
reply=RS.getInt("reply_num");
click=RS.getInt("click_num");
showing(request,out,serial,title,speaker,providedate,reply,click,"Subject");
//-----------------显示下一级的回复内容
ResultSet RS1 = bbsBean.executeQuery("select * from board where parent_no=" + serial + " order by serial_no");
while (RS1.next()) {
out.print("<tr><td>");
serial=RS1.getString("serial_no");
title=RS1.getString("title");
speaker=RS1.getString("speaker");
providedate=RS1.getDate("provide_time");
reply=RS1.getInt("reply_num");
click=RS1.getInt("click_num");
showing(request,out,serial,title,speaker,providedate,reply,click,"Re");
}
RS1.close();
bbsBean.closeStmt();
//------------------------
}
}
RS.close();
bbsBean.closeStmt();
%>
<!--以下函数用于帖子内容显示 -->
<%!
void showing(HttpServletRequest request,JspWriter out,String serial,String title,String speaker, Date providedate,int reply,int click,String ReSign)
throws IOException {
if(ReSign=="Subject"){
out.print("<a href=bbsAnswer.jsp?serial=" + serial + " onClick=' return newwin(this.href);'>" + title + "</a>");
}
else{
out.print("<a href=bbsReply.jsp?serial=" + serial + " onClick=' return newwin(this.href);'>" + title + "</a>");
}
out.print("</td><td align='center'>");
out.print(speaker);
out.print("</td><td align='center'>");
out.print(providedate);
out.print("</td><td align='center'>");
out.print(reply);
out.print("</td><td align='center'>");
out.print(click);
out.print("</td><td align='center'>");
out.print("<a href='delete.jsp?id="+serial+"' onClick=' return newwin(this.href);'>删除</a>");
out.print("</td><td align='center'>");
out.print("<a href='update.jsp?id="+serial+"' onClick=' return newwin(this.href);'>加入</a>");
out.print("</td></tr>");
}
%>
<!--以下用于帖子分页显示 -->
<%
out.print("<tr>");
if (intPage < 1 )
intPage=1;
out.print("<form method='POST' name=fPageNum action='manage.jsp'>");
out.print("<p align='left'>>>分页 ");
if (intPage<2)
out.print("<font color='999966'>首页 上一页</font> ");
else{
out.print("<a href='manage.jsp?page=1'>首页</a> ");
out.print("<a href='manage.jsp?page=" + (intPage-1) + "'>上一页</a> " );
}
if( intPage-intPageCount>=0 )
out.print("<font color='999966'>下一页 尾页</font>" );
else{
out.print("<a href='manage.jsp?page=" + (intPage+1)+ "'>下一页</a> <a href='manage.jsp?page=" + intPageCount + "'>尾页</a>");
}
out.print(" 页次:<strong><font color=red>"+intPage+"</font>/"+intPageCount+"</strong>页 " );
out.print(" 共<b>"+totalRec+"</b>条记录 <b>"+pageLine+"</b>条/页 " );
out.print(" 转到第<input type='text' name='page' size=2 maxlength=10 class=smallInput value="+intPage+">");
out.print("页<input class=buttonface type='submit' value='GO' name='cndok'></span></p></form>" );
out.print("</td>");
out.print("</tr>");
out.print("</table>");
out.print("</center>");
%>
</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -