怎么在Struts+JSP+JavaBean做的论坛中删除贴子?

J2EE 码拜 10年前 (2015-05-10) 1273次浏览 0个评论
 

只能删除得了回复,但删除不了贴子?怎么办

关键代码如下:持久化类如下

package com.yxq.actionform;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.ValidatorForm;

public class BbsForm extends ValidatorForm {
	private String bbsId;
	private String bbsBoardID;
	private String bbsTitle;
	private String bbsContent;
	private String bbsSender;
	private String bbsFace="face0.gif";
	private String bbsSendTime;
	private String bbsAnswerNum;
	private String bbsLastUpdateUser;
	private String bbsLastUpdateTime;
	private String bbsOpTime;
	private String bbsIsTop;
	private String bbsToTopTime;
	private String bbsIsGood;
	private String bbsToGoodTime;

	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
		String validate=request.getParameter("validate");
		if(validate==null||validate.equals("")||!validate.equals("yes"))
			return null;
		else
			return super.validate(mapping, request);
	}
	public String getBbsAnswerNum() {
		return bbsAnswerNum;
	}
	public void setBbsAnswerNum(String bbsAnswerNum) {
		this.bbsAnswerNum = bbsAnswerNum;
	}
	public String getBbsBoardID() {
		return bbsBoardID;
	}
	public void setBbsBoardID(String bbsBoardID) {
		this.bbsBoardID = bbsBoardID;
	}
	public String getBbsContent() {
		return bbsContent;
	}
	public void setBbsContent(String bbsContent) {
		this.bbsContent = bbsContent;
	}
	public String getBbsFace() {
		return bbsFace;
	}
	public void setBbsFace(String bbsFace) {
		this.bbsFace = bbsFace;
	}
	public String getBbsId() {
		return bbsId;
	}
	public void setBbsId(String bbsId) {
		this.bbsId = bbsId;
	}
	public String getBbsIsGood() {
		return bbsIsGood;
	}
	public void setBbsIsGood(String bbsIsGood) {
		this.bbsIsGood = bbsIsGood;
	}
	public String getBbsIsTop() {
		return bbsIsTop;
	}
	public void setBbsIsTop(String bbsIsTop) {
		this.bbsIsTop = bbsIsTop;
	}
	public String getBbsLastUpdateTime() {
		return bbsLastUpdateTime;
	}
	public void setBbsLastUpdateTime(String bbsLastUpdateTime) {
		this.bbsLastUpdateTime = bbsLastUpdateTime;
	}
	public String getBbsLastUpdateUser() {
		return bbsLastUpdateUser;
	}
	public void setBbsLastUpdateUser(String bbsLastUpdateUser) {
		this.bbsLastUpdateUser = bbsLastUpdateUser;
	}
	public String getBbsOpTime() {
		return bbsOpTime;
	}
	public void setBbsOpTime(String bbsOpTime) {
		this.bbsOpTime = bbsOpTime;
	}
	public String getBbsSender() {
		return bbsSender;
	}
	public void setBbsSender(String bbsSender) {
		this.bbsSender = bbsSender;
	}
	public String getBbsSendTime() {
		return bbsSendTime;
	}
	public void setBbsSendTime(String bbsSendTime) {
		this.bbsSendTime = bbsSendTime;
	}
	public String getBbsTitle() {
		return bbsTitle;
	}
	public void setBbsTitle(String bbsTitle) {
		this.bbsTitle = bbsTitle;
	}
	public String getBbsToGoodTime() {
		return bbsToGoodTime;
	}
	public void setBbsToGoodTime(String bbsToGoodTime) {
		this.bbsToGoodTime = bbsToGoodTime;
	}
	public String getBbsToTopTime() {
		return bbsToTopTime;
	}
	public void setBbsToTopTime(String bbsToTopTime) {
		this.bbsToTopTime = bbsToTopTime;
	}
	public String getSubBbsTitle(int len){
		if(len<=0||len>this.bbsTitle.length())
			len=this.bbsTitle.length();
		return this.bbsTitle.substring(0,len)+"..";
	}
	public void clear(){
		bbsId="";
		bbsBoardID="";
		bbsTitle="";
		bbsContent="";
		bbsSender="";
		bbsFace="";
		bbsSendTime="";
		bbsAnswerNum="";
		bbsLastUpdateUser="";
		bbsLastUpdateTime="";
		bbsOpTime="";
		bbsIsTop="";
		bbsToTopTime="";
		bbsIsGood="";
		bbsToGoodTime="";
	}
}
Action如下:

package com.yxq.action;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.util.LabelValueBean;
import com.yxq.actionform.BbsAnswerForm;
import com.yxq.actionform.BbsForm;
import com.yxq.actionform.BoardForm;
import com.yxq.actionform.UserForm;
import com.yxq.dao.OpDB;
import com.yxq.model.CreatePage;
import com.yxq.tools.Change;
public class BbsAction extends MySuperAction {
	/** 显示指定版面中的所有根帖 */
	public ActionForward rootListShow(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
		super.setParams(request);
		HttpSession session=request.getSession();
		session.setAttribute("mainPage","/pages/show/bbs/listRootShow.jsp");

		String classId=request.getParameter("classId");
		String boardId=request.getParameter("boardId");
		if(classId==null||classId.equals(""))
			classId=(String)session.getAttribute("classId");
		else
			session.setAttribute("classId",classId);
		if(boardId==null||boardId.equals(""))
			boardId=(String)session.getAttribute("boardId");
		else
			session.setAttribute("boardId",boardId);

		/* 生成“跳转版面”下拉列表中的选项,这些选项应为当前论坛类别中的版面 */
		Vector<LabelValueBean> jumpBoard=new Vector<LabelValueBean>();
		List boardlist=(ArrayList)session.getAttribute("class"+classId);
		if(boardlist!=null&&boardlist.size()!=0){
			for(int i=0;i<boardlist.size();i++){
				BoardForm boardSingle=(BoardForm)boardlist.get(i);
				jumpBoard.add(new LabelValueBean(boardSingle.getBoardName(),boardSingle.getBoardId()));
				if(boardId.equals(boardSingle.getBoardId())){								//如果是当前版面
					session.setAttribute("boardMaster",boardSingle.getBoardMaster());		//保存当前版面的斑竹
					session.setAttribute("boardPcard",boardSingle.getBoardPcard());			//保存当前版面的公告
				}
			}
		}
		session.setAttribute("jumpBoard",jumpBoard);

		String sql="";
		Object[] params={boardId};
		OpDB myOp=new OpDB();

		/* 查询数据库,获取置顶帖子(不包括括精华帖子) */
		myOp.setMark(false);							//不进行分页显示
		sql="select * from tb_bbs where bbs_boardID=? and bbs_isTop=""1"" order by bbs_toTopTime DESC";
		List topbbslist=myOp.OpBbsListShow(sql, params);
		session.setAttribute("topbbslist",topbbslist);

		/* 查询数据库,获取其他帖子(包括精华帖子,也包括即是置顶,又是精华的帖子) */
		int perR=5;
		String currentP=request.getParameter("showpage");
		if(currentP==null||currentP.equals(""))
			currentP=(String)session.getAttribute("currentP");
		else
			session.setAttribute("currentP",currentP);
		String gowhich="user/listShow.do?method=rootListShow";

		myOp.setMark(true);								//进行分页显示
		myOp.setPageInfo(perR, currentP, gowhich);		//设置进行分页显示需要的信息

		sql="select * from tb_bbs where bbs_boardID=? and (bbs_isTop=""0"" or bbs_isGood=""1"") order by bbs_opTime DESC";
		List otherbbslist=myOp.OpBbsListShow(sql, params);
		CreatePage page=myOp.getPage();

		session.setAttribute("otherbbslist",otherbbslist);
		session.setAttribute("page",page);

		return mapping.findForward("success");
	}

	/** 查看某个根帖 */
	public ActionForward openShow(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
		HttpSession session=request.getSession();
		session.setAttribute("mainPage","/pages/show/bbs/openRootShow.jsp");

		String bbsId=request.getParameter("bbsId");
		if(bbsId==null||bbsId.equals(""))
			bbsId=(String)session.getAttribute("bbsId");
		else
			session.setAttribute("bbsId",bbsId);

		String sql="";
		Object[] params={bbsId};
		OpDB myOp=new OpDB();

		/*********** 查询tb_bbs数据表,获取要查看的根帖 ***********/
		sql="select * from tb_bbs where bbs_id=?";
		BbsForm bbsRootSingle=myOp.OpBbsSingleShow(sql, params);
		session.setAttribute("bbsRootSingle",bbsRootSingle);

		/* 查询tb_user数据表,获取该根帖发表者信息 */
		String asker=bbsRootSingle.getBbsSender();
		sql="select * from tb_user where user_name=?";
		params[0]=asker;
		UserForm askUser=myOp.OpUserSingleShow(sql, params);
		session.setAttribute("askUser",askUser);

		/* 获取进行分页显示需要的信息 */
		int perR=6;
		String currentP=request.getParameter("showpage");
		if(currentP==null||currentP.equals(""))
			currentP=(String)session.getAttribute("currentPopen");
		else
			session.setAttribute("currentPopen",currentP);
		String gowhich="user/openShow.do?method=openShow";

		myOp.setMark(true);								//进行分页显示
		myOp.setPageInfo(perR, currentP, gowhich);		//设置进行分页显示需要的信息

		/*********** 查询tb_bbsAnswer数据表,获取根帖的回复帖 ***********/
		sql="select * from tb_bbsAnswer where bbsAnswer_rootID=? order by bbsAnswer_sendTime";
		params[0]=bbsId;
		List answerbbslist=myOp.OpBbsAnswerListShow(sql, params);
		CreatePage page=myOp.getPage();

		session.setAttribute("answerbbslist",answerbbslist);
		session.setAttribute("page",page);

		/* 查询tb_user数据表,获取当前回复帖发表者信息 */
		sql="select * from tb_user where user_name=?";
		Map answerMap=new HashMap();
		for(int i=0;i<answerbbslist.size();i++){
			String answerer=((BbsAnswerForm)answerbbslist.get(i)).getBbsAnswerSender();
			if(!answerMap.containsKey(answerer)){
				params[0]=answerer;
				UserForm answerUser=myOp.OpUserSingleShow(sql, params);
				answerMap.put(answerer,answerUser);
			}
		}
		session.setAttribute("answerMap",answerMap);

		return mapping.findForward("success");
	}

	/** 查看精华帖 */
	public ActionForward goodListShow(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
		super.setParams(request);
		HttpSession session=request.getSession();
		session.setAttribute("mainPage","/pages/show/bbs/goodListShow.jsp");
		OpDB myOp=new OpDB();

		int perR=5;
		String currentP=request.getParameter("showpage");
		if(currentP==null||currentP.equals(""))
			currentP=(String)session.getAttribute("currentPgood");
		else
			session.setAttribute("currentPgood",currentP);
		String gowhich="user/goodListShow.do?method=goodListShow";

		myOp.setMark(true);								//进行分页显示
		myOp.setPageInfo(perR, currentP, gowhich);		//设置进行分页显示需要的信息

		String sql="select * from tb_bbs where bbs_isGood=""1"" order by bbs_toGoodTime DESC";
		List goodlist=myOp.OpBbsListShow(sql,null);
		CreatePage page=myOp.getPage();

		session.setAttribute("goodlist",goodlist);
		session.setAttribute("page",page);

		return mapping.findForward("success");
	}

	/** 发表帖子 */
	public ActionForward addBbs(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
		HttpSession session=request.getSession();
		session.setAttribute("mainPage","/pages/add/bbsAdd.jsp");

		String validate=request.getParameter("validate");
		if(validate==null||validate.equals("")||!validate.equals("yes")){
			return mapping.findForward("showAddJSP");
		}
		//接下面
else{
			BbsForm bbsForm=(BbsForm)form;

			String	boardId=(String)session.getAttribute("boardId");
			String 	bbsTitle=Change.HTMLChange(bbsForm.getBbsTitle());
			String 	bbsContent=Change.HTMLChange(bbsForm.getBbsContent());
			String 	bbsSender=((UserForm)session.getAttribute("logoner")).getUserName();
			String 	bbsSendTime=Change.dateTimeChange(new Date());
			String 	bbsFace=bbsForm.getBbsFace();
			String 	bbsOpTime=bbsSendTime;
			String 	bbsIsTop="0";
			String 	bbsToTopTime="";
			String 	bbsIsGood="0";
			String 	bbsToGoodTime="";

			String sql="insert into tb_bbs values(null,?,?,?,?,now(),?,?,?,null,?,null)";
			Object[] params={boardId,bbsTitle,bbsContent,bbsSender,bbsFace,bbsOpTime,bbsIsTop,bbsIsGood};

			ActionMessages messages=new ActionMessages();
			OpDB myOp=new OpDB();
			int i=myOp.OpUpdate(sql,params);
			if(i<=0){
				System.out.println("发表帖子失败!");
				messages.add("userOpR",new ActionMessage("luntan.bbs.add.E"));
				saveErrors(request,messages);
				return mapping.findForward("error");
			}
			else{
				System.out.println("发表帖子成功!");
				session.setAttribute("currentP","1");
				messages.add("userOpR",new ActionMessage("luntan.bbs.add.S"));
				bbsForm.clear();
				saveErrors(request,messages);
				return mapping.findForward("success");
			}
		}
	}

	/** 回复帖子 */
	public ActionForward answerBbs(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
		HttpSession session=request.getSession();
		BbsAnswerForm bbsAnswerForm=(BbsAnswerForm)form;

		String  rootId=(String)session.getAttribute("bbsId");
		String 	bbsTitle=Change.HTMLChange(bbsAnswerForm.getBbsAnswerTitle());
		String 	bbsContent=Change.HTMLChange(bbsAnswerForm.getBbsAnswerContent());
		String 	bbsSender=((UserForm)session.getAttribute("logoner")).getUserName();
		String 	bbsSendTime=Change.dateTimeChange(new Date());
		String 	bbsFace=bbsAnswerForm.getBbsFace();

		String sql="insert into tb_bbsAnswer values(null,?,?,?,?,?,?)";
		Object[] params=new Object[6];

		params[0]=rootId;
		params[1]=bbsTitle;
		params[2]=bbsContent;
		params[3]=bbsSender;
		params[4]=bbsSendTime;
		params[5]=bbsFace;

		ActionMessages messages=new ActionMessages();
		String forwardPath="";

		OpDB myOp=new OpDB();
		int i=myOp.OpUpdate(sql, params);
		if(i<=0){
			System.out.println("回复帖子失败!");
			forwardPath="error";
			messages.add("userOpR",new ActionMessage("luntan.bbs.answerR.E"));
		}
		else{
			System.out.println("回复帖子成功!");
			forwardPath="success";
			messages.add("userOpR",new ActionMessage("luntan.bbs.answerR.S"));
			bbsAnswerForm.clear();
		}
		saveErrors(request,messages);
		return mapping.findForward(forwardPath);
	}

	/** 将帖子提前
	 *  @throws UnsupportedEncodingException */
	public ActionForward toFirstBbs(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException{
		HttpSession session=request.getSession();
		UserForm logoner=(UserForm)session.getAttribute("logoner");

		String bbsId=request.getParameter("bbsId");						//获取被提前帖子的ID
		String bbsSender=request.getParameter("bbsSender");				//获取被提前帖子的发布者
		bbsSender=new String(bbsSender.getBytes("ISO-8859-1"));
		String time=Change.dateTimeChange(new Date());					//获取操作时间
		String lognerAble=logoner.getUserAble();						//获取当前登录用户的权限
		String lognerName=logoner.getUserName();						//获取当前登录用户的用户名
		String master=(String)session.getAttribute("boardMaster");		//获取当前版面的斑竹

		if(bbsId==null)
			bbsId="-1";
		if(bbsSender==null)
			bbsSender="";

		String forwardPath="";
		ActionMessages messages=new ActionMessages();

		/* 如果当前登录的用户是帖子的发表者、帖子所属版面的斑竹、管理员 */
		if(lognerAble.equals("2")||lognerName.equals(master)||lognerName.equals(bbsSender)){
			if(bbsId!=null&&!bbsId.equals("")){
				Object[] params={time,bbsId};
				String sql="update tb_bbs set bbs_opTime=? where bbs_id=?";
				OpDB myOp=new OpDB();
				int i=myOp.OpUpdate(sql,params);
				if(i<=0){
					System.out.println("提前帖子失败");
					forwardPath="error";
					messages.add("userOpR",new ActionMessage("luntan.bbs.first.E"));
				}
				else{
					System.out.println("提前帖子成功!");
					forwardPath="success";
					messages.add("userOpR",new ActionMessage("luntan.bbs.first.S"));
				}
			}
			else{
				forwardPath="error";
			}
		}
		else{
			System.out.println("您没有权限提前该帖子!");
			forwardPath="error";
			messages.add("userOpR",new ActionMessage("luntan.bbs.first.N"));
		}
		saveErrors(request,messages);
		return mapping.findForward(forwardPath);
	}

	/** 删除根帖 
	 * @throws UnsupportedEncodingException ?
	 * ----------未成功!*/
	public ActionForward deleteRootBbs(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException{
		HttpSession session=request.getSession();
		UserForm logoner=(UserForm)session.getAttribute("logoner");

		String bbsId=request.getParameter("bbsId");						//获取要删除帖子的ID
		String bbsSender=request.getParameter("bbsSender");				//获取要删除帖子的发布者
		bbsSender=new String(bbsSender.getBytes("ISO-8859-1"));
		String lognerAble=logoner.getUserAble();						//获取当前登录用户的权限
		String lognerName=logoner.getUserName();						//获取当前登录用户的用户名
		String master=(String)session.getAttribute("boardMaster");		//获取当前斑竹

		if(bbsId==null)
			bbsId="-1";
		if(bbsSender==null)
			bbsSender="";

		ActionMessages messages=new ActionMessages();

    	//如果当前登录的用户是帖子的发表者、帖子所属版面的斑竹、管理员
		if(lognerAble.equals("2")||lognerName.equals(master)||lognerName.equals(bbsSender)){
			if(bbsId!=null&&!bbsId.equals("")){
				String sql="delete tb_bbs where bbs_id=?";
				Object[] params={bbsId};

				OpDB myOp=new OpDB();
				int i=myOp.OpUpdate(sql,params);
				if(i<=0){
					System.out.println("删除出错!");
					messages.add("userOpR",new ActionMessage("luntan.bbs.deleteRoot.E"));
					saveErrors(request,messages);
				}
				else{								//删除成功后,要返回列表显示根帖的页面,该页面有:查看某版面下所有根帖的页面、查看我的帖子的页面、查看精华帖子的页面
					System.out.println("删除成功!");
					messages.add("userOpR",new ActionMessage("luntan.bbs.deleteRoot.S"));
					saveErrors(request,messages);
					ActionForward forward=new ActionForward("/"+session.getAttribute("servletPath")+"?method="+session.getAttribute("method"));		//因为返回的页面存在以上三种情况,所以返回的视图要在程序中动态指定
					return forward;
				}
			}
			return mapping.findForward("error");
		}
		else{
			System.out.println("您没有权限删除该帖子!");
			messages.add("userOpR",new ActionMessage("luntan.bbs.deleteRoot.N"));
			saveErrors(request,messages);
			return mapping.findForward("error");
		}
	}

	/** 查看帖子的发表者的详细信息 */
	public ActionForward getUserSingle(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
		HttpSession session=request.getSession();

		String userName=request.getParameter("userName");
		if(userName==null)
			userName="";
		try {
			userName=new String(userName.getBytes("ISO-8859-1"),"gb2312");
		} catch (UnsupportedEncodingException e) {
			userName="";
			e.printStackTrace();
		}

		ActionMessages messages=new ActionMessages();
		String forwardPath="";

		String sql="select * from tb_user where user_name=?";
		Object[] params={userName};

		OpDB myOp=new OpDB();
		UserForm bbsUser=myOp.OpUserSingleShow(sql, params);

		if(bbsUser==null){
			System.out.println("查看帖子的发表者失败!");
			forwardPath="error";
			messages.add("userOpR",new ActionMessage("luntan.bbs.sender.E"));
		}
		else{
			System.out.println("查看帖子的发表者成功!");
			forwardPath="success";
			session.setAttribute("bbsUserSingle",bbsUser);
			session.setAttribute("mainPage","/pages/show/user/bbsUserSingle.jsp");
		}
		saveErrors(request,messages);
		return mapping.findForward(forwardPath);
	}
}
JSP如下:

<%@ page contentType="text/html; charset=gb2312"%>
<%@ page import="java.util.*,com.yxq.actionform.UserForm" %>
<%@ taglib uri="struts-html" prefix="html" %>
<%@ taglib uri="struts-bean" prefix="bean" %>
<%@ taglib uri="struts-logic" prefix="logic" %>

<html>
  <head>
    <title>查看根帖</title>
  </head>
  <body>
    <center>
      <!-- ****************显示根帖信息**************** -->
      <html:link linkName="top"/>
      <table border="1" width="99%" cellspacing="0" cellpadding="0" bordercolor="#E3E3E3" bordercolorlight="#E0E0E0" bordercolordark="white" rules="all" style="margin-top:8;word-break:break-all">
          <tr height="30"><td colspan="3" background="images/index/classT.jpg" style="text-indent:5"><b><font color="white">■ 显示根帖</font></b></td></tr>
          <tr height="30" bgcolor="#F0F0F0">
              <td style="text-indent:5" width="27%">★ 楼主</td>
              <td colspan="2">【主题】<bean:write name="bbsRootSingle" property="bbsTitle" filter="false"/></td>
          </tr>
          <tr bgcolor="#F9F9F9">
	          <!-- 发帖者信息 -->
              <td rowspan="3" align="center" valign="top">
                  <table width="95%" height="180" border="0" cellspacing="0" cellpadding="0" style="margin-top:3">
                      <tr height="35%">
                          <td align="center" width="30%"><img src="images/face/user/${askUser.userFace}" style="border:1 solid;border-color:#E3E3E3"></td> 
                          <td style="text-indent:10">
                              <a href="bbs/user/getUserSingle.do?method=getUserSingle&userName=${sessionScope.bbsRootSingle.bbsSender}">
                                  <b><bean:write name="askUser" property="userName" filter="false"/></b>
                              </a>
                          </td>
                      </tr>
                      <tr>
                          <td align="center">性别:</td>
                          <td style="text-indent:10">
                              <bean:write name="askUser" property="userSex"/>
                          </td>
                      </tr>
                      <tr>
                          <td align="center">OICQ:</td>
                          <td style="text-indent:10">
                              <bean:write name="askUser" property="userOICQ"/>
                          </td>
                      </tr>
                      <tr>
                          <td align="center">来自:</td>
                          <td style="text-indent:10">
                              <bean:write name="askUser" property="subUserFrom[10]" filter="false"/>
                          </td>
                      </tr>
                      <!-- “返回”超链接 -->
                      <tr height="30"><td colspan="2" style="text-indent:70"><a href="${sessionScope.servletPath}?method=${sessionScope.method}">[返回]</a></td></tr>
                  </table>
              </td>
              <!-- 根帖信息 -->
              <td width="10%">【表情】<img src="images/face/bbs/${sessionScope.bbsRootSingle.bbsFace}"></td>
              <td height="30" align="right">发表时间:『<bean:write name="bbsRootSingle" property="bbsSendTime"/>』&nbsp;</td>
          </tr>
          <tr height="130"><td colspan="2" valign="top" style="padding-top:6;padding-left:6;padding-right:6;padding-bottom:6"><bean:write name="bbsRootSingle" property="bbsContent" scope="session" filter="false"/></td></tr>
          
          <!-- 实现对根帖进行操作的超链接 -->
          <tr height="30" bgcolor="#F9F9F9">
              <td align="right" colspan="2">
                  ◆<html:link href="view/indexTemp.jsp" anchor="answer">回复该帖&nbsp;</html:link>
                  
                  <!-- 如果该贴不是精华帖子,并且不是置顶帖子(实际上就是普通帖子) -->
                  <logic:notEqual value="1" name="bbsRootSingle" property="bbsIsGood" scope="session">
                      <logic:notEqual value="1" name="bbsRootSingle" property="bbsIsTop">
                          <!-- 显示“将帖子提前”超链接 -->
                          ◆<a href="needLogin/firstBbs.do?method=toFirstBbs&bbsId=${sessionScope.bbsRootSingle.bbsId}&bbsSender=${sessionScope.bbsRootSingle.bbsSender}" title="帖子所属者/楼主/管理员操作">将帖子提前</a>&nbsp;
                      </logic:notEqual>
                  </logic:notEqual>
                  
                  <!-- 如果该帖不是置顶帖子 -->
                  <logic:notEqual value="1" name="bbsRootSingle" property="bbsIsTop">
					  <!-- 显示“置顶帖子”超链接 -->
                      ◆<a href="needLogin/admin/doTopGood.do?method=setTopBbs&bbsId=${sessionScope.bbsRootSingle.bbsId}" title="管理员操作">置顶帖子</a>&nbsp;
                  </logic:notEqual>
                  
                  <!-- 如果该帖不是精华帖子 -->
                  <logic:notEqual value="1" name="bbsRootSingle" property="bbsIsGood">
                      <!-- 显示“设为精华帖”超链接 -->
                      ◆<a href="needLogin/admin/doTopGood.do?method=setGoodBbs&bbsId=${sessionScope.bbsRootSingle.bbsId}" title="管理员操作">设为精华帖</a>&nbsp;                  
                  </logic:notEqual> 
                                   
                   <!-- 显示“删除帖子”超链接 -->
                  ◆<a href="needLogin/deleteRoot.do?method=deleteRootBbs&bbsId=${sessionScope.bbsRootSingle.bbsId}&bbsSender=${sessionScope.bbsRootSingle.bbsSender}" title="帖子所属者/楼主/管理员操作">删除帖子</a>&nbsp;
              </td>
          </tr>
      </table>
      
      <!-- ****************分页导航**************** -->
      <table  border="1" width="99%" cellspacing="0" cellpadding="0" bordercolor="#E3E3E3" bordercolorlight="#E3E3E3" bordercolordark="white">
          <tr height="30">
              <td align="right" background="images/index/boardE.jpg">
                  <jsp:include flush="true" page="/pages/page.jsp">
                      <jsp:param name="gowhich" value="user/openShow.do?method=openShow"/>
                  </jsp:include>
              </td>
          </tr>
      </table>
      
      <!-- ****************显示回复帖子**************** -->      
      <table border="1" width="99%" cellspacing="0" cellpadding="0" bordercolor="#E3E3E3" bordercolorlight="#E3E3E3" bordercolordark="white" style="margin-top:2;word-break:break-all">
          <tr height="30"><td background="images/index/classT.jpg" style="text-indent:5"><b><font color="white">■ 显示回复帖子</font></b></td></tr>
      </table>
      <!-- 不存在回复帖子列表 -->
      <logic:notPresent name="answerbbslist" scope="session">
          <table border="1" width="99%" cellspacing="0" cellpadding="0" bordercolor="#E3E3E3" bordercolorlight="#E3E3E3" bordercolordark="white" rules="all">
              <tr height="70" bgcolor="#F9F9F9"><td align="center"><li>暂时没有回复帖!</li></td></tr>
          </table>
      </logic:notPresent>      
      <!-- 存在回复帖子列表 -->
      <logic:present name="answerbbslist" scope="session">
      	  <!-- 回复帖子列表为空 -->
          <logic:empty name="answerbbslist" scope="session">
              <table border="1" width="99%" cellspacing="0" cellpadding="0" bordercolor="#E3E3E3" bordercolorlight="#E3E3E3" bordercolordark="white" rules="all">
                  <tr height="70" bgcolor="#F9F9F9"><td align="center"><li>暂时没有回复帖!</li></td></tr>
              </table>                        
          </logic:empty>
          <!-- 回复帖子列表不为空 -->
          <logic:notEmpty name="answerbbslist" scope="session">
              <!-- 遍历回复帖子列表 -->
              <logic:iterate id="answerbbsSingle" name="answerbbslist" indexId="idind">
              <bean:define id="answererName" name="answerbbsSingle" property="bbsAnswerSender"/>
              <table border="1" width="99%" cellspacing="0" cellpadding="0" bordercolor="#E3E3E3" bordercolorlight="#E3E3E3" bordercolordark="white" rules="all" style="word-break:break-all">
                  <tr height="25" bgcolor="#F0F0F0">
                      <td style="text-indent:5" width="27%">▲${(page.currentP-1)*page.perR+(idind+1)} 楼</td>
                      <td colspan="2">【回复主题】<bean:write name="answerbbsSingle" property="bbsAnswerTitle" filter="false"/></td>              
                  </tr>                  
                  <tr bgcolor="#F9F9F9">
	                  <!-- 回复者信息 -->	                  
	                  
	                  <logic:iterate id="singleMap" name="answerMap">
	                      <logic:equal value="${answererName}" name="singleMap" property="key">
                              <bean:define id="answerSingle" name="singleMap" property="value"/>
	                      </logic:equal>
	                  </logic:iterate>
                      
                      <td rowspan="3" align="center" valign="top">
                          <table width="95%" height="150" border="0" cellspacing="0" cellpadding="0" style="margin-top:3">
                              <tr height="35%">
                                  <td align="center" width="30%"><img src="images/face/user/${answerSingle.userFace}" style="border:1 solid;border-color:#E0E0E0"></td>
                                  <td style="text-indent:10">
                                      <a href="bbs/user/getUserSingle.do?method=getUserSingle&userName=${answererName}">
                                          <b>${answerMap[answererName].userName}</b>
                                      </a>
                                  </td>
                              </tr>
                              <tr>
                                  <td align="right">性别:</td>
                                  <td style="text-indent:10">
                                      ${answerMap[answererName].userSex}
                                  </td>
                              </tr>
                              <tr>
                                  <td align="right">OICQ:</td>
                                  <td style="text-indent:10">
                                      ${answerMap[answererName].userOICQ}
                                  </td>
                              </tr>
                              <tr>
                          //接下面
10分
好长好长,我都看不下去了啊。。。。
5分
楼主,可以学一下SSH吗?保证你不后悔!我的WEB程序从JSP内嵌到SSH一共5个版本了,每次都重写,但是真的不后悔!
5分
因为这样的代码太繁杂、后期维护会让你抓狂的
5分
SSH代码很繁琐  

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明怎么在Struts+JSP+JavaBean做的论坛中删除贴子?
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!