📄 viewpost.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"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>查看贴内容</title>
<%@page import="java.util.*" %></head><body>
<table width="921" height="900" border="2" align="center">
<tr>
<th height="51" colspan="2" scope="col"> </th>
<th width="298" rowspan="2" scope="col"><div align="center"><span class="STYLE2">软件工程交流论坛</span></div></th>
<th colspan="2" scope="col"> </th>
</tr>
<%
int pagesize =5;//默认每页显示帖数
int pageview =1;//默认第一次显示的页数
int pagecount =0;//设置默认总页数
String id;
String currauthor;
String control;
id = (String)session.getAttribute("name");
currauthor = (String)session.getAttribute("author");
control = (String)session.getAttribute("control");//控制位
String bbsstate =(String)request.getAttribute("bbsstate");//得到目前所在版块
String master =(String)session.getAttribute("master");//获取master位
String lv = (String)session.getAttribute("lv");
String pageView = (String)request.getAttribute("pageview");//获取要显示的页码
String url = (String)request.getAttribute("postid");
String currtitle = (String)request.getAttribute("title");//获取当前帖子题目
System.out.println("当前viewpost.jsp页面的bbsstate值为;"+bbsstate);
pageview = Integer.parseInt(pageView);
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"> </td>
<td height="23"> </td>
<td width="298" height="23"> </td>
<td height="23"> </td>
<td height="23"> </td>
</tr>
<%} %>
<%
if(!id.equals("visitor")){%>
<tr>
<td height="23"> </td>
<td height="23"> </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> 未读<%=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="850" border="3" align="center">
<tr>
<td>
<a href="/bbs_design/index.jsp">论坛主页</a> >>
<jsp:useBean id="dbsw" scope="session" class="bean.dbwrite.DBStateWrite" />
<a href="/bbs_design/ReqServlet?action=bbsform1&bbsstate=<%=bbsstate %>&pageview=1"><%=dbsw.FindStateName(bbsstate) %></a> >><%=currtitle %>
</td>
</tr>
<tr>
<td height="202">
<%
String author="";
String title="";
String floor="";
String content="";
String del="";
String time="";
int head=0;
int image=0;
Vector a;
Vector b;
String postid = new String(request.getParameter("action").getBytes("iso-8859-1"),"GB2312");//存储ID
%>
<table border="0">
<%
a = (Vector)request.getAttribute("postcontent");//获取内容
b = (Vector)request.getAttribute("postfloor");//获取可编辑楼号
int size = a.size();
int size_floor =b.size();//带添加标示的楼层总数
pagecount = (size/6-1+pagesize)/pagesize;//将总页数赋给pagecount
System.out.println("获取到的总贴数"+size/6);
System.out.println("获取到的属于自己的总楼数"+size_floor);
int startnum=1;
int endnum=5;
startnum = (pageview-1)*pagesize;
if(pageview<pagecount)
endnum = startnum-1+pagesize;
else endnum = size/6-1;
System.out.println("内容帖子startnum="+startnum+" endnum"+endnum);
Enumeration e = b.elements();
while(e.hasMoreElements()){
System.out.println(e.nextElement());
}
int s=0;
for(int i=startnum; i<=endnum; i++){
author = (String)a.elementAt(i*6);
title = (String)a.elementAt(i*6+1);
floor = (String)a.elementAt(i*6+2);
content = (String)a.elementAt(i*6+3);
del = (String)a.elementAt(i*6+4);
time = (String)a.elementAt(i*6+5);
System.out.println("本楼HEAD值为:"+head+" 获取本楼时间:"+time);
%>
<tr>
<td colspan=5><%=author %></td>
<td colspan=120><%=title %></td>
<td >[<%=time %>]</td>
<td colspan=3><%=floor %>楼  </td>
<%
if(!currauthor.equals(author)&& !author.equals("游客") && !currauthor.equals("游客")){%>
<td><a href="/bbs_design/ReqMessage?action=sendto&whosend=<%=id %>&author=<%=author %>">短消息</a></td>
<%
}
%>
<%
if(size_floor!=0 && master.equals("0")){
if(s<size_floor){
String t_floor = (String)b.elementAt(s);//调出一个待比较楼号
while(Integer.parseInt(t_floor)<startnum){
s++;
if(s<size_floor)
t_floor = (String)b.elementAt(s);
else break;
}
System.out.println("待比较楼号:"+t_floor+" 当前楼号:"+floor);
if(t_floor.equals(floor) && !id.equals("游客")){
if(del.equals("0")){
%>
<td><a href="/bbs_design/ReqForm?action=modify&postid=<%=postid %>&floor=<%=floor %>&currauthor=<%=currauthor %>&bbsstate=<%=bbsstate %>&face=0">编辑</a></td>
<td><a href="/bbs_design/ReqForm?action=delpost&postid=<%=postid %>&floor=<%=floor %>&currauthor=<%=currauthor %>&bbsstate=<%=bbsstate %>">删除</a></td>
<% }
s++;
}
}
}
else if(master.equals("1")){
if(s<size_floor){
String t_floor = (String)b.elementAt(s);//调出一个待比较楼号
while(Integer.parseInt(t_floor)<startnum){
s++;
if(s<size_floor)
t_floor = (String)b.elementAt(s);
else break;
}
System.out.println("待比较楼号:"+t_floor+" 当前楼号:"+floor);
if(t_floor.equals(floor) && !id.equals("游客")){
if(del.equals("0")){
%>
<td><a href="/bbs_design/ReqForm?action=modify&postid=<%=postid %>&floor=<%=floor %>&currauthor=<%=currauthor %>&bbsstate=<%=bbsstate %>&face=0">编辑</a></td>
<% }
s++;
}
}
%>
<%
if(del.equals("0")){%>
<td><a href="/bbs_design/ReqForm?action=delpost&postid=<%=postid %>&floor=<%=floor %>&currauthor=<%=currauthor %>&bbsstate=<%=bbsstate %>">删除</a></td>
<%
}
else{%>
<td><a href="/bbs_design/ReqForm?action=undelpost&postid=<%=postid %>&floor=<%=floor %>&currauthor=<%=currauthor %>&bbsstate=<%=bbsstate %>">解封</a></td>
<%
}
%>
<td><a href="/bbs_design/ReqForm?action=addscore&postauthor=<%=author %>&bbsstate=<%=bbsstate %>">加分</a></td>
<%
}
%>
<tr>
<jsp:useBean id="dbr0" scope="session" class="bean.readdb.DBRead" />
<%
head = dbr0.DBReader_Head(url,floor);
if(head ==1){%>
<td colspan=5><img src="file:///E:/eclipse/workspace/bbs_design/WebContent/head/1.jpg" ></img></td>
<%
}
else if(head==2){%>
<td colspan=5><img src="file:///E:/eclipse/workspace/bbs_design/WebContent/head/2.jpg" ></img></td>
<%
}
else if(head==3){%>
<td colspan=5><img src="file:///E:/eclipse/workspace/bbs_design/WebContent/head/3.jpg" ></img></td>
<%
}
else if(head==4){%>
<td colspan=5><img src="file:///E:/eclipse/workspace/bbs_design/WebContent/head/4.jpg" ></img></td>
<%
}
else{%>
<td colspan=5></td>
<%
}
%>
<%
if(del.equals("0")){%>
<td colspan=150><%=content %></td><br>
<%
}
else{%>
<td colspan=150>该帖子已被删除</td><br>
<%
}
%>
<jsp:useBean id="dbr" scope="session" class="bean.readdb.DBRead" />
<%
if(!author.equals("游客")){%>
<tr><td>发帖:<%=dbr.DBReader_Post(author) %></td>
<tr><td>积分:<%=dbr.DBReader_Score(author) %></td>
<%
}
%>
<%
image = dbr.DBReader_Image(url,floor);
System.out.println("读取到的image:"+image);
if(image >0 && del.equals("0")){
String temp1 ="";
String temp2 ="";
String filename="";
for(int n=0; n<url.length();n++){
if(url.charAt(n)=='*'){
temp1 = url.substring(0,n);
temp2 = url.substring(n+1);
break;
}
}
filename =temp1+"_"+temp2+"_"+floor;
System.out.println("要显示的第一个图片名称:"+filename+"_"+image+".jpg");
for(int h=1; h<=image; h++){%>
<tr><td colspan=5></td>
<td><img src="file:///C:/j2ee/bbs_design/WebContent/image/<%=filename %>_<%=image %>.jpg" ></img></td>
<%
}
}
%>
<%
}
%>
</table>
</td>
</tr>
<tr>
<td height="21">
分页显示
<%
for(int i=1; i<=pagecount; i++){%>
<a href="/bbs_design/OpenPost?action=<%=url %>&currauthor=<%=currauthor %>&currid=<%=id %>&bbsstate=<%=bbsstate %>&lv=<%=lv %>&pageview=<%=i %>&title=<%=title %>">[<%=i %>]</a>
<%
}
%>
<%
if(pageview>1){%>
<a href="/bbs_design/OpenPost?action=<%=url %>&currauthor=<%=currauthor %>&currid=<%=id %>&bbsstate=<%=bbsstate %>&lv=<%=lv %>&pageview=<%=pageview-1 %>&title=<%=title %>">上一页</a>
<%
}
if(pageview<pagecount){%>
<a href="/bbs_design/OpenPost?action=<%=url %>&currauthor=<%=currauthor %>&currid=<%=id %>&bbsstate=<%=bbsstate %>&lv=<%=lv %>&pageview=<%=pageview+1 %>&title=<%=title %>">下一页</a>
<%
}
%>
</td>
</tr>
<tr>
<td height="250">
<%
floor=String.valueOf(Integer.parseInt(floor)+1);
%>
<form action="/bbs_design/ReqForm" method="get">
用户<input type="text" name = "author" value=<%=currauthor %> >
回复<input type="text" name = "title" value=<%=title %> ><br>
内容<textarea name="recontent" rows=10 cols=40></textarea><br>
<input type="hidden" name="action" value="repost">
<input type="hidden" name="floor" value=<%=floor %>>
<input type="hidden" name="postid" value=<%=postid %>>
<input type="hidden" name="bbsstate" value=<%=bbsstate %>>
<input type="submit" value="提交" >
</form>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -