作者主页:夜未央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


- public class userAction {
- private TUserDAO userDAO;
- private int id;
- private String userName;
- private String userPw;
- private String realName;
- private String email;
-
- private String message;
- private String path;
-
- public TUserDAO getUserDAO() {
- return userDAO;
- }
-
- public void setUserDAO(TUserDAO userDAO) {
- this.userDAO = userDAO;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public String getUserPw() {
- return userPw;
- }
-
- public void setUserPw(String userPw) {
- this.userPw = userPw;
- }
-
- public String getRealName() {
- return realName;
- }
-
- public void setRealName(String realName) {
- this.realName = realName;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public String userLogout(){
- Map session= ActionContext.getContext().getSession();
- session.remove("user");
- this.setMessage("退出成功");
- this.setPath("bbs/jump.jsp");
- return "succeed";
- }
-
- public String userReg(){
- TUser user = new TUser();
-
- user.setUserName(userName);
- user.setUserPw(userPw);
- user.setEmail(email);
- user.setRealName(realName);
- user.setUserType(1);
- user.setIsDel(0);
-
- userDAO.save(user);
-
- Map session= ActionContext.getContext().getSession();
- session.put("user", user);
- this.setMessage("注册成功");
- this.setPath("bbs/jump.jsp");
- return "succeed";
- }
-
- public String userMana()
- {
- List userList = userDAO.getHibernateTemplate().find("from TUser where userType=1 and isDel=0");
- Map request=(Map)ServletActionContext.getContext().get("request");
-
- request.put("userList", userList);
- return ActionSupport.SUCCESS;
- }
-
- public String userDel()
- {
- userDAO.getHibernateTemplate().bulkUpdate("update TUser set isDel=1 where id="+id);
-
- this.setMessage("操作成功");
- this.setPath("userMana.action");
- return "succeed";
- }
-
- }
- public class userAction {
- private TUserDAO userDAO;
- private int id;
- private String userName;
- private String userPw;
- private String realName;
- private String email;
-
- private String message;
- private String path;
-
- public TUserDAO getUserDAO() {
- return userDAO;
- }
-
- public void setUserDAO(TUserDAO userDAO) {
- this.userDAO = userDAO;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public String getUserPw() {
- return userPw;
- }
-
- public void setUserPw(String userPw) {
- this.userPw = userPw;
- }
-
- public String getRealName() {
- return realName;
- }
-
- public void setRealName(String realName) {
- this.realName = realName;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public String userLogout(){
- Map session= ActionContext.getContext().getSession();
- session.remove("user");
- this.setMessage("退出成功");
- this.setPath("bbs/jump.jsp");
- return "succeed";
- }
-
- public String userReg(){
- TUser user = new TUser();
-
- user.setUserName(userName);
- user.setUserPw(userPw);
- user.setEmail(email);
- user.setRealName(realName);
- user.setUserType(1);
- user.setIsDel(0);
-
- userDAO.save(user);
-
- Map session= ActionContext.getContext().getSession();
- session.put("user", user);
- this.setMessage("注册成功");
- this.setPath("bbs/jump.jsp");
- return "succeed";
- }
-
- public String userMana()
- {
- List userList = userDAO.getHibernateTemplate().find("from TUser where userType=1 and isDel=0");
- Map request=(Map)ServletActionContext.getContext().get("request");
-
- request.put("userList", userList);
- return ActionSupport.SUCCESS;
- }
-
- public String userDel()
- {
- userDAO.getHibernateTemplate().bulkUpdate("update TUser set isDel=1 where id="+id);
-
- this.setMessage("操作成功");
- this.setPath("userMana.action");
- return "succeed";
- }
-
- }
- ublic class topicAction extends ActionSupport{
- private TForumsDAO forumsDAO;
- private TTopicDAO topicDAO;
- private TThreadsDAO threadsDAO;
- private int fid;
- private int pid;
-
- private String message;
- private String path;
-
- public String topicMana(){
- List topicList = new ArrayList();
-
- 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";
- Session session = topicDAO.getSessionFactory().openSession();
- List objList = session.createSQLQuery(sql).list();
- for (Object object : objList) {
- Object[] objTopic = (Object[])object;
-
- TTopic topic = new TTopic();
- topic.setPid((Integer)objTopic[0]);
- topic.setAuthor((String)objTopic[1]);
- topic.setFname((String)objTopic[2]);
- topic.setSubject((String)objTopic[3]);
- topic.setView((Integer)objTopic[4]);
- topic.setReplies((Integer)objTopic[5]);
- topic.setAddtime((Date)objTopic[6]);
-
- topicList.add(topic);
- }
-
- Map request=(Map)ServletActionContext.getContext().get("request");
- request.put("topicList", topicList);
- return SUCCESS;
- }
-
- public String topicDel(){
- String delSql = "delete from TTopic where pid="+pid;
- topicDAO.getHibernateTemplate().bulkUpdate(delSql);
-
- delSql = "delete from TThreads where pid="+pid;
- topicDAO.getHibernateTemplate().bulkUpdate(delSql);
-
- this.setMessage("操作成功");
- this.setPath("topicMana.action");
- return "succeed";
- }
-
- public String topicview(){
- List topicList = topicDAO.getHibernateTemplate().find("from TTopic where fid="+fid +"order by addtime desc");
- for (Object object : topicList) {
- TTopic topic = (TTopic)object;
- topic.setStyle("folder_common");
-
- String sql = "from TThreads where pid="+topic.getPid()+" order by addtime desc limit 1";
- TThreads lastSub = (TThreads)threadsDAO.getHibernateTemplate().find(sql).get(0);
-
- if(topic.getReplies()>0){
- //判断是否是最新回复
- if(newSub(lastSub.getAddtime())){
- topic.setStyle("folder_new");
- }
- }
- topic.setLastsub(lastSub);
- }
-
- TForums forums = forumsDAO.findById(fid);
-
- Map request=(Map)ServletActionContext.getContext().get("request");
- request.put("topicList", topicList);
- request.put("forums", forums);
- return ActionSupport.SUCCESS;
- }
-
- /**
- * 判断是否有新主题
- * @return
- */
- private boolean newSub(Date addtime){
- boolean result = false;
-
- Calendar calendar = Calendar.getInstance();
-
- calendar.setTime(addtime);
- long timeadd = calendar.getTimeInMillis();
-
- calendar.setTime(new Date());
- long timethis = calendar.getTimeInMillis();
-
- long theday = (timethis - timeadd) / (1000 * 60 * 60 * 24);
-
- if(theday<7)
- result = true;
- return result;
- }
-
- public TForumsDAO getForumsDAO() {
- return forumsDAO;
- }
- public void setForumsDAO(TForumsDAO forumsDAO) {
- this.forumsDAO = forumsDAO;
- }
- public TTopicDAO getTopicDAO() {
- return topicDAO;
- }
- public void setTopicDAO(TTopicDAO topicDAO) {
- this.topicDAO = topicDAO;
- }
- public TThreadsDAO getThreadsDAO() {
- return threadsDAO;
- }
- public void setThreadsDAO(TThreadsDAO threadsDAO) {
- this.threadsDAO = threadsDAO;
- }
- public int getPid() {
- return pid;
- }
- public void setPid(int pid) {
- this.pid = pid;
- }
- public int getFid() {
- return fid;
- }
- public void setFid(int fid) {
- this.fid = fid;
- }
- public String getMessage() {
- return message;
- }
- public void setMessage(String message) {
- this.message = message;
- }
- public String getPath() {
- return path;
- }
- public void setPath(String path) {
- this.path = path;
- }
- }
如果也想学习本系统,下面领取。回复:130ssh