资源简介
帖子的增删改查,后台权限的操作,论坛的基本功能留言、发帖。适合java新手学习
包含数据库脚本,论坛源码
代码片段和文件信息
package action;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import pojo.Bbsreplyinfo;
import pojo.Bbssectioninfo;
import pojo.Bbstopicinfo;
import pojo.Bbsuser;
import dao.BbsreplyinfoDAO;
import dao.BbssectioninfoDAO;
import dao.BbstopicinfoDAO;
import dao.BbsuserDAO;
import form.ReplyForm;
public class ReplyAction extends DispatchAction {
//用户回复帖子
public ActionForward makeReplyPsts(ActionMapping mapping ActionForm form
HttpServletRequest request HttpServletResponse response)
throws Exception {
String tid = request.getParameter(“tid“);//主贴ID
String tsid = request.getParameter(“tsid“);//主贴所在版块ID
String userid = request.getParameter(“userid“);//回帖人ID(既登录用户)
System.out.println(tsid+“ “+userid+“ “+tid);
ReplyForm rf = (ReplyForm)form;
System.out.println(rf.getRcontents()+“ “+rf.getRtopic());
Bbsreplyinfo reply = new Bbsreplyinfo();
Bbstopicinfo topic = new Bbstopicinfo();
Bbssectioninfo section = new Bbssectioninfo();
Bbsuser user = new Bbsuser();
BbsuserDAO userDAO = new BbsuserDAO();
BbssectioninfoDAO sectioninfoDAO = new BbssectioninfoDAO();
BbstopicinfoDAO topicDAO = new BbstopicinfoDAO();
BbsreplyinfoDAO replyDAO = new BbsreplyinfoDAO();
//将所属板块查找出来,并放入topic中
user = userDAO.findById(new Long(Long.parseLong(userid)));
section = sectioninfoDAO.findById(new Long(Long.parseLong(tsid)));
topic = topicDAO.findById(new Long(Long.parseLong(tid)));
reply.setBbssectioninfo(section);
reply.setBbsuser(user);
reply.setBbstopicinfo(topic);
reply.setRpublishtime(new Date());
reply.setRtopic(rf.getRtopic());
reply.setRcontents(rf.getRcontents());
//调用save方法
replyDAO.save(reply);
return replyPostsContent(mappingformrequestresponse);
}
//根据帖子ID来显示帖子信息(用户回复帖子之后跳转这里)
public ActionForward replyPostsContent(ActionMapping mapping ActionForm form
HttpServletRequest request HttpServletResponse response)
throws Exception {
int tid = Integer.parseInt(request.getParameter(“tid“));
BbstopicinfoDAO topicDAO = new BbstopicinfoDAO();
BbsreplyinfoDAO replyDAO = new BbsreplyinfoDAO();
List list = topicDAO.findByTopicId(tid);
request.setAttribute(“list“list);
List replyList = replyDAO.findByTopicId(tid);
request.setAttribute(“replyList“ replyList);
return mapping.findForward(“postsContent“);
}
//在admin中显示班所有帖子
public ActionForward adminPostsList2(ActionMapping mapping ActionForm form
HttpServletRequest request HttpServletResponse response)
throws Exception {
//String sid = request.getParameter(“sid“);
BbssectioninfoDAO sectionDAO = new BbssectioninfoDAO();
List
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 880 2009-11-01 22:57 testBBS\.classpath
文件 513 2010-09-29 21:27 testBBS\.myhibernatedata
文件 294 2009-11-02 09:47 testBBS\.myme
文件 262 2010-07-17 08:46 testBBS\.mystrutsdata
文件 1698 2010-07-17 08:48 testBBS\.project
文件 406 2010-06-22 10:45 testBBS\.settings\.jsdtscope
文件 334 2010-06-22 10:45 testBBS\.settings\org.eclipse.jdt.core.prefs
文件 49 2010-06-22 10:45 testBBS\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2010-06-22 10:45 testBBS\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 5499 2010-10-17 16:46 testBBS\src\action\ReplyAction.java
文件 5289 2010-10-17 00:45 testBBS\src\action\SectionAction.java
文件 9771 2010-10-17 14:08 testBBS\src\action\TopicAction.java
文件 11276 2010-10-18 14:41 testBBS\src\action\UserAction.java
文件 90 2010-07-17 08:46 testBBS\src\com\yourcompany\struts\ApplicationResources.properties
文件 348 2010-09-29 21:27 testBBS\src\dao\ba
文件 3911 2010-10-17 13:01 testBBS\src\dao\BbsreplyinfoDAO.java
文件 4094 2010-10-17 00:48 testBBS\src\dao\BbssectioninfoDAO.java
文件 8726 2010-10-18 09:48 testBBS\src\dao\BbstopicinfoDAO.java
文件 4955 2010-10-18 09:58 testBBS\src\dao\BbsuserDAO.java
文件 214 2010-09-29 21:27 testBBS\src\dao\Iba
文件 780 2010-08-25 08:28 testBBS\src\filter\ChineseFilter.java
文件 1609 2010-10-04 12:12 testBBS\src\form\ReplyForm.java
文件 902 2010-09-30 10:15 testBBS\src\form\SectionForm.java
文件 1923 2010-09-30 10:27 testBBS\src\form\TopicForm.java
文件 2514 2010-09-29 21:29 testBBS\src\form\UserForm.java
文件 1122 2010-10-13 20:55 testBBS\src\hibernate.cfg.xm
文件 1758 2010-10-13 13:12 testBBS\src\pojo\Bbsreplyinfo.hbm.xm
文件 2445 2010-09-29 21:27 testBBS\src\pojo\Bbsreplyinfo.java
文件 1795 2010-10-13 13:12 testBBS\src\pojo\Bbssectioninfo.hbm.xm
文件 2054 2010-09-30 10:13 testBBS\src\pojo\Bbssectioninfo.java
............此处省略267个文件信息
评论
共有 条评论