第一范文网 - 专业文章范例文档资料分享平台

BBS论文

来源:用户分享 时间:2025/10/6 11:25:27 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

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

}

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论文 的文档
BBS论文.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c45vcu96tt63cwgi88zvh_8.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top