• SSH动漫论坛的设计与实现


    作者主页:夜未央5788

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

    项目介绍

    本项目分为前后台,前台为普通用户操作,后台为管理员操作;
    前台主要功能:
    登录、注册、版块查看、帖子查看、发表帖子、回复评论等;

    后台主要功能:
    分区管理:分区添加、分区管理;
    版块管理:版块添加、版块管理;
    子版块管理:子版块添加、子版块管理;
    主题管理:主题管理;

    会员管理;

    演示视频:点此查看

    由于本程序规模不大,可供课程设计,毕业设计学习演示之用

    环境需要

    1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
    2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
    3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
    4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
    5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 

    6.数据库:MySql 5.7等版本均可;

    技术栈

    1. 后端:Spring Struts Hibernate 

    2. 前端:JSP+css+javascript+jQuery

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
    2.使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
    若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,
    3. 将项目中WebRoot/WEB-INF/applicationContext.xml配置文件中的数据库配置改为自己的配置,然后运行;
    4. 在浏览器中访问地址:http://localhost:8080/
    管理员用户名密码:admin/admin
    普通用户名密码:user/123456

    运行截图

    文档截图

     

     

    前台页面

     

     

     

     

    后台页面

     

     

     

     

    相关代码

    用户管理控制器

    1. public class userAction {
    2. private TUserDAO userDAO;
    3. private int id;
    4. private String userName;
    5. private String userPw;
    6. private String realName;
    7. private String email;
    8. private String message;
    9. private String path;
    10. public TUserDAO getUserDAO() {
    11. return userDAO;
    12. }
    13. public void setUserDAO(TUserDAO userDAO) {
    14. this.userDAO = userDAO;
    15. }
    16. public int getId() {
    17. return id;
    18. }
    19. public void setId(int id) {
    20. this.id = id;
    21. }
    22. public String getUserName() {
    23. return userName;
    24. }
    25. public void setUserName(String userName) {
    26. this.userName = userName;
    27. }
    28. public String getUserPw() {
    29. return userPw;
    30. }
    31. public void setUserPw(String userPw) {
    32. this.userPw = userPw;
    33. }
    34. public String getRealName() {
    35. return realName;
    36. }
    37. public void setRealName(String realName) {
    38. this.realName = realName;
    39. }
    40. public String getEmail() {
    41. return email;
    42. }
    43. public void setEmail(String email) {
    44. this.email = email;
    45. }
    46. public String getMessage() {
    47. return message;
    48. }
    49. public void setMessage(String message) {
    50. this.message = message;
    51. }
    52. public String getPath() {
    53. return path;
    54. }
    55. public void setPath(String path) {
    56. this.path = path;
    57. }
    58. public String userLogout(){
    59. Map session= ActionContext.getContext().getSession();
    60. session.remove("user");
    61. this.setMessage("退出成功");
    62. this.setPath("bbs/jump.jsp");
    63. return "succeed";
    64. }
    65. public String userReg(){
    66. TUser user = new TUser();
    67. user.setUserName(userName);
    68. user.setUserPw(userPw);
    69. user.setEmail(email);
    70. user.setRealName(realName);
    71. user.setUserType(1);
    72. user.setIsDel(0);
    73. userDAO.save(user);
    74. Map session= ActionContext.getContext().getSession();
    75. session.put("user", user);
    76. this.setMessage("注册成功");
    77. this.setPath("bbs/jump.jsp");
    78. return "succeed";
    79. }
    80. public String userMana()
    81. {
    82. List userList = userDAO.getHibernateTemplate().find("from TUser where userType=1 and isDel=0");
    83. Map request=(Map)ServletActionContext.getContext().get("request");
    84. request.put("userList", userList);
    85. return ActionSupport.SUCCESS;
    86. }
    87. public String userDel()
    88. {
    89. userDAO.getHibernateTemplate().bulkUpdate("update TUser set isDel=1 where id="+id);
    90. this.setMessage("操作成功");
    91. this.setPath("userMana.action");
    92. return "succeed";
    93. }
    94. }
    95. public class userAction {
    96. private TUserDAO userDAO;
    97. private int id;
    98. private String userName;
    99. private String userPw;
    100. private String realName;
    101. private String email;
    102. private String message;
    103. private String path;
    104. public TUserDAO getUserDAO() {
    105. return userDAO;
    106. }
    107. public void setUserDAO(TUserDAO userDAO) {
    108. this.userDAO = userDAO;
    109. }
    110. public int getId() {
    111. return id;
    112. }
    113. public void setId(int id) {
    114. this.id = id;
    115. }
    116. public String getUserName() {
    117. return userName;
    118. }
    119. public void setUserName(String userName) {
    120. this.userName = userName;
    121. }
    122. public String getUserPw() {
    123. return userPw;
    124. }
    125. public void setUserPw(String userPw) {
    126. this.userPw = userPw;
    127. }
    128. public String getRealName() {
    129. return realName;
    130. }
    131. public void setRealName(String realName) {
    132. this.realName = realName;
    133. }
    134. public String getEmail() {
    135. return email;
    136. }
    137. public void setEmail(String email) {
    138. this.email = email;
    139. }
    140. public String getMessage() {
    141. return message;
    142. }
    143. public void setMessage(String message) {
    144. this.message = message;
    145. }
    146. public String getPath() {
    147. return path;
    148. }
    149. public void setPath(String path) {
    150. this.path = path;
    151. }
    152. public String userLogout(){
    153. Map session= ActionContext.getContext().getSession();
    154. session.remove("user");
    155. this.setMessage("退出成功");
    156. this.setPath("bbs/jump.jsp");
    157. return "succeed";
    158. }
    159. public String userReg(){
    160. TUser user = new TUser();
    161. user.setUserName(userName);
    162. user.setUserPw(userPw);
    163. user.setEmail(email);
    164. user.setRealName(realName);
    165. user.setUserType(1);
    166. user.setIsDel(0);
    167. userDAO.save(user);
    168. Map session= ActionContext.getContext().getSession();
    169. session.put("user", user);
    170. this.setMessage("注册成功");
    171. this.setPath("bbs/jump.jsp");
    172. return "succeed";
    173. }
    174. public String userMana()
    175. {
    176. List userList = userDAO.getHibernateTemplate().find("from TUser where userType=1 and isDel=0");
    177. Map request=(Map)ServletActionContext.getContext().get("request");
    178. request.put("userList", userList);
    179. return ActionSupport.SUCCESS;
    180. }
    181. public String userDel()
    182. {
    183. userDAO.getHibernateTemplate().bulkUpdate("update TUser set isDel=1 where id="+id);
    184. this.setMessage("操作成功");
    185. this.setPath("userMana.action");
    186. return "succeed";
    187. }
    188. }

     主题控制器

    1. ublic class topicAction extends ActionSupport{
    2. private TForumsDAO forumsDAO;
    3. private TTopicDAO topicDAO;
    4. private TThreadsDAO threadsDAO;
    5. private int fid;
    6. private int pid;
    7. private String message;
    8. private String path;
    9. public String topicMana(){
    10. List topicList = new ArrayList();
    11. String sql = "select ta.pid,author,name,`subject`,view,replies,addtime from t_topic ta left join t_forums tb on ta.fid=tb.fid";
    12. Session session = topicDAO.getSessionFactory().openSession();
    13. List objList = session.createSQLQuery(sql).list();
    14. for (Object object : objList) {
    15. Object[] objTopic = (Object[])object;
    16. TTopic topic = new TTopic();
    17. topic.setPid((Integer)objTopic[0]);
    18. topic.setAuthor((String)objTopic[1]);
    19. topic.setFname((String)objTopic[2]);
    20. topic.setSubject((String)objTopic[3]);
    21. topic.setView((Integer)objTopic[4]);
    22. topic.setReplies((Integer)objTopic[5]);
    23. topic.setAddtime((Date)objTopic[6]);
    24. topicList.add(topic);
    25. }
    26. Map request=(Map)ServletActionContext.getContext().get("request");
    27. request.put("topicList", topicList);
    28. return SUCCESS;
    29. }
    30. public String topicDel(){
    31. String delSql = "delete from TTopic where pid="+pid;
    32. topicDAO.getHibernateTemplate().bulkUpdate(delSql);
    33. delSql = "delete from TThreads where pid="+pid;
    34. topicDAO.getHibernateTemplate().bulkUpdate(delSql);
    35. this.setMessage("操作成功");
    36. this.setPath("topicMana.action");
    37. return "succeed";
    38. }
    39. public String topicview(){
    40. List topicList = topicDAO.getHibernateTemplate().find("from TTopic where fid="+fid +"order by addtime desc");
    41. for (Object object : topicList) {
    42. TTopic topic = (TTopic)object;
    43. topic.setStyle("folder_common");
    44. String sql = "from TThreads where pid="+topic.getPid()+" order by addtime desc limit 1";
    45. TThreads lastSub = (TThreads)threadsDAO.getHibernateTemplate().find(sql).get(0);
    46. if(topic.getReplies()>0){
    47. //判断是否是最新回复
    48. if(newSub(lastSub.getAddtime())){
    49. topic.setStyle("folder_new");
    50. }
    51. }
    52. topic.setLastsub(lastSub);
    53. }
    54. TForums forums = forumsDAO.findById(fid);
    55. Map request=(Map)ServletActionContext.getContext().get("request");
    56. request.put("topicList", topicList);
    57. request.put("forums", forums);
    58. return ActionSupport.SUCCESS;
    59. }
    60. /**
    61. * 判断是否有新主题
    62. * @return
    63. */
    64. private boolean newSub(Date addtime){
    65. boolean result = false;
    66. Calendar calendar = Calendar.getInstance();
    67. calendar.setTime(addtime);
    68. long timeadd = calendar.getTimeInMillis();
    69. calendar.setTime(new Date());
    70. long timethis = calendar.getTimeInMillis();
    71. long theday = (timethis - timeadd) / (1000 * 60 * 60 * 24);
    72. if(theday<7)
    73. result = true;
    74. return result;
    75. }
    76. public TForumsDAO getForumsDAO() {
    77. return forumsDAO;
    78. }
    79. public void setForumsDAO(TForumsDAO forumsDAO) {
    80. this.forumsDAO = forumsDAO;
    81. }
    82. public TTopicDAO getTopicDAO() {
    83. return topicDAO;
    84. }
    85. public void setTopicDAO(TTopicDAO topicDAO) {
    86. this.topicDAO = topicDAO;
    87. }
    88. public TThreadsDAO getThreadsDAO() {
    89. return threadsDAO;
    90. }
    91. public void setThreadsDAO(TThreadsDAO threadsDAO) {
    92. this.threadsDAO = threadsDAO;
    93. }
    94. public int getPid() {
    95. return pid;
    96. }
    97. public void setPid(int pid) {
    98. this.pid = pid;
    99. }
    100. public int getFid() {
    101. return fid;
    102. }
    103. public void setFid(int fid) {
    104. this.fid = fid;
    105. }
    106. public String getMessage() {
    107. return message;
    108. }
    109. public void setMessage(String message) {
    110. this.message = message;
    111. }
    112. public String getPath() {
    113. return path;
    114. }
    115. public void setPath(String path) {
    116. this.path = path;
    117. }
    118. }

    如果也想学习本系统,下面领取。回复:130ssh 

  • 相关阅读:
    使用Puppeteer构建博客内容的自动标签生成器
    AOP全局异常处理
    【尚硅谷React】——React全家桶笔记
    Jmeter(七):jmeter连接数据库/中元件的执行顺序&作用域详解
    逐字稿 | ViT论文逐段精读【论文精读】
    请编码实现动物世界的继承关系……定义一个体育活动类(Sports)作为基类……编写一个程序,并满足如下要求……
    头条百科怎么创建才容易通过,上头条百科的技巧
    国外芯片,为什么有中文资料和网页?
    ES6知识点总结——学习网站及环境搭建
    四、【React-Router6】高亮 NavLink
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/125626779