⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bbsform1.jsp

📁 一个小型的BBS系统
💻 JSP
字号:
<%@ page language="java" contentType="text/html; charset=gb2312"
    pageEncoding="gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="bean.dbwrite.DBStateWrite"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%@page import="java.util.*" %>
<title>论坛版块</title>
</head>
<body>


<table width="921" height="600" border="2" align="center">
  <tr>
    <th height="51" colspan="2" scope="col">&nbsp;</th>
    <th width="298" rowspan="2" scope="col"><div align="center"><span class="STYLE2">软件工程交流论坛</span></div></th>
    <th colspan="2" scope="col">&nbsp;</th>
  </tr>


<%
int pagesize =5;//默认每页显示帖数
int pageview =1;//默认第一次显示的页数
int pagecount =0;//设置默认总页数
int perpagecount =1;//设置默认每帖页数
System.out.println("开始绘制bbsform1");
String id; 
String currauthor;

id = (String)session.getAttribute("name");
currauthor = (String)session.getAttribute("author");
String bbsstate = (String)request.getAttribute("bbsstate");//得到目前所在版块
String master =(String)session.getAttribute("master");
String pageView = (String)request.getAttribute("pageview");//获取要显示的页码
pageview = Integer.parseInt(pageView);
System.out.println("当前所在版块:"+bbsstate+"当前master位为:"+master);



if(id!=null){
	%>
	   <tr>
	    <td width="150"><div align="center">用户ID:<%=id %></div></td>
	    <td width="154" height="17"> <div align="center">昵称: <%=currauthor %></div></td>
	    <td width="170"><div align="center"><a href="/bbs_design/ReqServlet?action=login">用户登陆</a> </div></td>
	    <td width="115"><div align="center"><a href="/bbs_design/ReqServlet?action=register">新用户注册</a></div></td>
	  </tr>
		 
	   <%	
	}
	else{
		id ="visitor";
		session.setAttribute("name","visitor");
		session.setAttribute("author","游客");
	%>
	  <tr>
	    <td width="150"><div align="center">用户ID:<%=id %></div></td>
	    <td width="154" height="17"> <div align="center">昵称: 游客</div></td>
	    <td width="170"><div align="center"><a href="/bbs_design/ReqServlet?action=login">用户登陆</a> </div></td>
	    <td width="115"><div align="center"><a href="/bbs_design/ReqServlet?action=register">新用户注册</a></div></td>
	  </tr>
	  <tr>
	    <td height="23">&nbsp;</td>
	    <td height="23">&nbsp;</td>
	    <td width="298" height="23">&nbsp;</td>
	    <td height="23">&nbsp;</td>
	    <td height="23">&nbsp;</td>
	  </tr>
	   <%} %> 
	   <%
	if(!id.equals("visitor")){%>
		
	     <tr>
	    <td height="23">&nbsp;</td>
	    <td height="23">&nbsp;</td>
	     <td width="298" height="23">
	     <jsp:useBean id="cm" scope="session" class="bean.check.CheckMessage" />
	     <a href="/bbs_design/ReqServlet?action=message&userid=<%=id %>">短消息</a>&nbsp未读<%=cm.CheckUnReadMessage(id) %>个</td>
	     <td height="23"><a href="/bbs_design/ReqServlet?action=usercontrolform&userid=<%=id %>">控制面板</a> </td>
	     <td height="23"><a href="/bbs_design/ReqServlet?action=quit">安全退出</a></td>
	     </tr>

	<%}
	%>
	    
	  <tr>
	    <td height="4" colspan="5"><div align="center">
	    
	    
	    
	<table width="700" border="3">
  <tr>
    <td height="26">
    <jsp:useBean id="dbsw" scope="session" class="bean.dbwrite.DBStateWrite" />
    <a href="/bbs_design/index.jsp">论坛主页</a> >> <%=dbsw.FindStateName(bbsstate) %></td>
  </tr>
  <tr>
    <td height="26"><a href="/bbs_design/ReqForm?action=write&bbsstate=<%=bbsstate %>" >发表主题</a></td>
  </tr>
  <tr>
    <td height="187">
    
    
    <table width="700" border="3" align="center">
  <tr>
    <th width="92" height="34" scope="col">置顶</th>
    <th width="167" scope="col" colspan=20>题目</th>
    <th width="88" scope="col">发贴人</th>
    <th width="75" scope="col">最近回复人</th>
    <th width="78" scope="col">查看人数</th>
    <th width="78" scope="col">回复人数</th>
  </tr>
  
  
  
<%
Vector top = new Vector();
top =(Vector)request.getAttribute("top");
int size_top =top.size();

if(size_top!=0){%>

<% 

System.out.println("置顶帖容量:"+size_top/9);
if(size_top!=0){
	for(int i=0; i<size_top/9; i++){
		String title = (String)top.elementAt(i*9);
		String url = (String)top.elementAt(i*9+1);
		String author = (String)top.elementAt(i*9+2);
		String lastupdate = (String)top.elementAt(i*9+3);
		String number = (String)top.elementAt(i*9+4);
		String count = (String)top.elementAt(i*9+5);
		String recount = (String)top.elementAt(i*9+6);
		String del = (String)top.elementAt(i*9+7);
		String lv = (String)top.elementAt(i*9+8);
		perpagecount = (Integer.parseInt(recount)+pagesize)/pagesize;//将总页数赋给perpagecount
		
		if(lv.equals("1"))
			lv = "置顶I";
		else if(lv.equals("2"))
			lv = "置顶II";
		else lv = "置顶III";
		%>
	<tr>
    <td width="92" height="22" scope="col"><%=lv %></td>
    
		<%
		int tt=i+1;
		System.out.println("置顶帖"+tt+"传递参数为:动作"+url+" 当前作者"+currauthor+" 当前用户ID"+id+" 当前版块"+bbsstate);
		%>
		<td width="167" scope="col" colspan=20><a href="/bbs_design/OpenPost?action=<%=url %>&currauthor=<%=currauthor %>&currid=<%=id %>&bbsstate=<%=bbsstate %>&lv=<%=lv %>&pageview=1&title=<%=title %>"><%=title %></a>
		<%
		if(perpagecount>1){
			for(int k=1; k<=perpagecount; k++){%>
				<a href="/bbs_design/OpenPost?action=<%=url %>&currauthor=<%=currauthor %>&currid=<%=id %>&bbsstate=<%=bbsstate %>&lv=<%=lv %>&pageview=<%=k %>&title=<%=title %>">[<%=k %>]</a>
		<% 
			}
		}
		%>
		</td>
		
		 <td width="88" scope="col"><%=author %></td>
    	 <td width="75" scope="col"><%=lastupdate %></td>
    	 <td width="78" scope="col"><%=count %></td>
 	     <td width="78" scope="col"><%=recount %></td>
		
		<%
		if(master.equals("1")){ %>
			<th width="72" scope="col"><a href="/bbs_design/ReqForm?action=canceltop&bbsstate=<%=bbsstate %>&topid=<%=url %>&lv=<%=lv %>">取消置顶</th>	
	<% 	}	
	}//end for
}//end if
}
%>
</table>
    
    </td>
  </tr>
  <tr>
    <td height="276">
    
    
    <table width="700" border="3">
  <tr>
    <th width="51" height="31" scope="col">状态</th>
    <th width="152" scope="col" colspan=20>题目</th>
    <th width="57" scope="col">发贴人</th>
    <th width="72" scope="col">最近回复人</th>
    <th width="55" scope="col">查看人数</th>
    <th width="62" scope="col">回复人数</th>
    <th width="63" scope="col">&nbsp;</th>
    <th width="126" scope="col">&nbsp;</th>
    
  </tr>
 		
<%
Vector c ;

String temp = (String)request.getAttribute("temp");
String isempty = (String)request.getAttribute("isempty");

if(isempty.equals("0")){%>
<%=temp %>
<% 	

}
else{
	c = (Vector)request.getAttribute("post");
	
	int size = c.size();
	pagecount = (size/9-1+pagesize)/pagesize;//将总页数赋给pagecount
	
	System.out.println("普通帖容量"+size/9);
	int startnum=1;
	int endnum=5;
	startnum = (pageview-1)*pagesize+1;
	if(pageview<pagecount)
		endnum = startnum-1+pagesize;
	else endnum = size/9;
	System.out.println("普通帖循环startnum="+startnum+" endnum"+endnum);
	for(int i=startnum; i<=endnum; i++){//控制显示帖数次数及编号
		String l="0";
		int s=0;
		int j=1;
		for(j=1; j<=size/9; j++){//控制具体显示帖子的序号
			s=j*9-5;//定位number字段
			l=(String)c.elementAt(s);
			System.out.println("取出的楼号"+l);
			if(l.equals(String.valueOf(i))){
				break;
			}
			
		}
		
		String title = (String)c.elementAt(s-4);
		String url = (String)c.elementAt(s-3);
		String author = (String)c.elementAt(s-2);
		String lastupdate = (String)c.elementAt(s-1);
		String count = (String)c.elementAt(s+1);
		String recount = (String)c.elementAt(s+2);
		String del = (String)c.elementAt(s+3);
		String level = (String)c.elementAt(s+4);
		
		
		perpagecount = (Integer.parseInt(recount)+pagesize)/pagesize;//将总页数赋给pagecount
		%>
		
	<tr>
	<%
	if(del.equals("0")){%>
	    <td width="51" height="23" scope="col">普通</td>
<%		
	}
	else {%>

	   <td width="51" height="23" scope="col">已封</td>
<% 		
	}
	%>
	
	<%
	if(del.equals("0")){
	%>
		<td width="152" scope="col" colspan=20><a href="/bbs_design/OpenPost?action=<%=url %>&currauthor=<%=currauthor %>&currid=<%=id %>&bbsstate=<%=bbsstate %>&lv=<%=level %>&pageview=1&title=<%=title %>"><%=title %></a>
		<%
		if(perpagecount>1){
			for(int k=1; k<=perpagecount; k++){%>
				<a href="/bbs_design/OpenPost?action=<%=url %>&currauthor=<%=currauthor %>&currid=<%=id %>&bbsstate=<%=bbsstate %>&lv=<%=level %>&pageview=<%=k %>&title=<%=title %>">[<%=k %>]</a>
		<% 
			}
		}
		%>
		</td>
	<%
	} 
	else{%>
		<td width="152" scope="col" colspan=20><a href="/bbs_design/cannotopen.jsp?bbsstate=<%=bbsstate %>"><%=title %></a></td>
<% 			
	}
	%>
	<td width="57" scope="col"><%=author %></td>
    <td width="72" scope="col"><%=lastupdate %></td>
    <td width="55" scope="col"><%=count %></td>
    <td width="62" scope="col"><%=recount %></td>
    	
<% 		
		if(master.equals("1")){
			
		%>
		<%
		if(del.equals("0")){%>
			<td width="63" scope="col"><a href="/bbs_design/ReqForm?action=closepost&closenum=<%=url %>&bbsstate=<%=bbsstate %>">封贴</a></td>
		<% 
		}
		else{%>
			<td width="63" scope="col"><a href="/bbs_design/ReqForm?action=unclosepost&closenum=<%=url %>&bbsstate=<%=bbsstate %>">解封</a></td>
		<% 
		}
		%>
		
		<td width="126" scope="col" colspan=3>
			<form action="/bbs_design/ReqForm" method="get">
			<select name="posttop" id="2">
 				<option value="1">置顶I</option>
 				<option value="2">置顶II</option>
 				<option value="3">置顶III</option>
			</select>
				<input type="hidden" name="action" value="top">
				<input type="hidden" name="postid" value="<%=url %>">
				<input type="hidden" name="bbsstate" value=<%=bbsstate %>>
				<input type="submit" value="置顶" >
			</form>
			</td>
<% 		
		}
	}
}
%>
</table>
    
  </td>
  </tr>
  <tr>
    <td height="27">
    
    分页显示
<%
for(int i=1; i<=pagecount; i++){%>
	<a href="/bbs_design/ReqServlet?action=bbsform1&pageview=<%=i %>&bbsstate=<%=bbsstate %>">[<%=i %>]</a>
<%
}
%>
<%
if(pageview>1){%>
	<a href="/bbs_design/ReqServlet?action=bbsform1&pageview=<%=pageview-1 %>&bbsstate=<%=bbsstate %>">上一页</a>
<% 
}
if(pageview<pagecount){%>
	<a href="/bbs_design/ReqServlet?action=bbsform1&pageview=<%=pageview+1 %>&bbsstate=<%=bbsstate %>">下一页</a>
<% 
}

%>
    </td>
  </tr>
</table>
	    	    	    	   	 
</div>   
</td>
  </tr>
</table>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -