BBS论文

2026/1/22 17:21:20

哈尔滨商业大学毕业设计(论文)

}

Date date=new Date(); user.setLastTime(date); userDao.updateUser(user);

request.getSession().removeAttribute(\

return mapping.findForward(\(4)

查看版面:首页显示BBS的版块及主要信息,点击版块名进入版块下会

显示主题列表,点击主题名可以进入主题页面。

首页index.jsp采用 方法将请求交给BbsAction.java处理,在BbsAction中从数据库取出所有版块的信息及每个版块下的最新主题信息,并将取出的数据保存在JSP的Session对象中,数据取出后交给bbs.jsp页面,在bbs.jsp页面中将取出的结果显示出来。

BbsAction.java的类主要代码如下: public class BbsAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form,

HttpServletRequest request, HttpServletResponse response) { // TODO Auto-generated method stub

WebApplicationContext ctx = WebApplicationContextUtils

.getWebApplicationContext(this.servlet.getServletContext());

TopicDao topicDao = (TopicDao) ctx.getBean(\UserDao userDao = (UserDao) ctx.getBean(\

ModuleDao moduleDao = (ModuleDao) ctx.getBean(\List listModule = moduleDao.getModule();

Map mapTopic = new TreeMap(); for (Module module : listModule) {

List list = topicDao.getTopicByModId(module.getId());// 根据Latest latestTopic =new Latest(); User user = null;

if (list != null & !list.isEmpty()) {

user = userDao.getUser(list.get(0).getUserId());// 根据第一条主题if (user != null) {

19

模块ID查询主题

的用户名ID查询用户名

哈尔滨商业大学毕业设计(论文) }

} (5)

}

}

}

latestTopic.setUserId(user.getId()); latestTopic.setUserName(user.getName()); latestTopic.setPubTime(list.get(0).getCreatTime());

mapTopic.put(module.getId(), latestTopic);

request.getSession().setAttribute(\request.getSession().setAttribute(\return mapping.findForward(\

查看主题:当用户在主页上点击版块名时,会产生一个动作,向服务器

产生一个请求,服务器将程序交给TopicAction.java处理,在TopicAction.java中取出模块下的所有主题及最后发表回复的作者的信息并将其存入request对象中,处理完之后返回到版块下的主题显示页面。

TopicAction.java类的部分代码如下:

public ActionForward select(ActionMapping mapping, ActionForm form,

20

HttpServletRequest request, HttpServletResponse response) {

// TODO Auto-generated method stub

WebApplicationContext ctx = WebApplicationContextUtils

.getWebApplicationContext(this.servlet.getServletContext());

ModuleDao moduleDao = (ModuleDao) ctx.getBean(\TopicDao topicDao = (TopicDao) ctx.getBean(\

ReTopicDao reTopicDao = (ReTopicDao) ctx.getBean(\UserDao userDao = (UserDao) ctx.getBean(\

int moduleId = Integer.parseInt(request.getParameter(\List listTopic = topicDao.getTopicByModId(moduleId);// 取出模块Module module = moduleDao.getModule(moduleId);// 取出模块 Map mapReTopic = new TreeMap

下的所有主题

LatestReTopic>();

哈尔滨商业大学毕业设计(论文)

} (6)

for (Topic topic : listTopic) { }

request.setAttribute(\request.setAttribute(\request.setAttribute(\return mapping.findForward(\

查看回复:用户在主题显示页面点击主题名时会产生查找主题信息动作,

LatestReTopic latestReTopic = new LatestReTopic();

List listReTopic = reTopicDao.getReTopicsByTopicId(topic

.getId());// 取出该主题下的回复

User topicUser = userDao.getUser(topic.getUserId());// 取出发表主题User reTopicUser = new User();

if (listReTopic != null && !listReTopic.isEmpty()) { }

latestReTopic.setTopicUserName(topicUser.getName()); mapReTopic.put(topic.getId(), latestReTopic);

reTopicUser = userDao.getUser(listReTopic.get(0).getUserId());// 取latestReTopic.setReTopicUserId(reTopicUser.getId()); latestReTopic.setReTopicUserName(reTopicUser.getName()); latestReTopic.setPubTime(listReTopic.get(0).getReTime()); latestReTopic.setReNum(listReTopic.size());

的用户ID及用户名

出最后发表回复的用户ID及用户名

系统将这个动作交给ReTopicAction.java来处理,在ReTopicAction.java中请求交给后台DAO,从DAO中取出数据表中的项,要取的内容有该主题所在的版块信息、该主题信息、该主题下的回复信息,该主题和其回复的作者的部分信息。

ReTopicAction.java的部分代码如下:

public ActionForward selectReTopic(ActionMapping mapping, ActionForm form,

HttpServletRequest request, HttpServletResponse response) {

.getWebApplicationContext(this.servlet.getServletContext());

21

WebApplicationContext ctx = WebApplicationContextUtils

哈尔滨商业大学毕业设计(论文)

TopicDao topicDao = (TopicDao) ctx.getBean(\

ReTopicDao reTopicDao = (ReTopicDao) ctx.getBean(\UserDao userDao = (UserDao) ctx.getBean(\GroupDao groupDao = (GroupDao) ctx.getBean(\IntegralDao integralDao = (IntegralDao) ctx.getBean(\ModuleDao moduleDao = (ModuleDao) ctx.getBean(\int topicId = Integer

.parseInt((String) request.getParameter(\

Topic topic = topicDao.getTopicById(topicId);

if(request.getSession().isNew()){//如果为新用户则点击数加一 }

Module module = moduleDao.getModule(topic.getModId()); User topicUser = userDao.getUser(topic.getUserId()); List listGroup = groupDao.getGroup();

List listReTopic = reTopicDao.getReTopicsByTopicId(topicId); Map mapReTopicUser = new TreeMap

for (ReTopic reTopic : listReTopic) {

ReTopicUser reTopicUser = new ReTopicUser();

User reTopiocUser = userDao.getUser(reTopic.getUserId()); if (reTopiocUser != null) {

Group group = groupDao.getGroup(reTopiocUser.getGroupId()); List listIngegral = integralDao.getIntegral(); if (listIngegral != null) {

for (Integral integral : listIngegral) {

if (integral.getIntegral() > reTopiocUser.getIntegral()) {

reTopicUser.setUsergrade(integral.getGrade()); break;

22

int hits=topic.getHits()+1; topic.setHits(hits);

topicDao.updateTopics(topic);

ReTopicUser>();


BBS论文.doc 将本文的Word文档下载到电脑
搜索更多关于: BBS论文 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219