• Java项目:SSM游戏点评网站


    作者主页:源码空间站2022

     简介: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.数据库:MySql 5.7版本;

    6.是否Maven项目:否;

    技术栈

    1. 后端:Spring+SpringMVC+Mybatis

    2. 前端:JSP+CSS+JavaScript+jQuery

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

    2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

    若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;

    3. 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置;
    4. 运行项目,在浏览器中输入http://localhost:8080/ 登录
    用户账号/密码: user/123456

    管理员账号/密码:admin/admin

    运行截图

    前台界面

    后台界面

     

    相关代码 

    AdminAction

    1. package com.action;
    2. import java.util.ArrayList;
    3. import java.util.List;
    4. import javax.annotation.Resource;
    5. import org.springframework.beans.factory.annotation.Autowired;
    6. import org.springframework.stereotype.Controller;
    7. import org.springframework.web.bind.annotation.RequestMapping;
    8. import com.entity.Admin;
    9. import com.service.AdminService;
    10. import com.util.PageHelper;
    11. import com.util.VeDate;
    12. //定义为控制器
    13. @Controller
    14. // 设置路径
    15. @RequestMapping(value = "/admin", produces = "text/plain;charset=utf-8")
    16. public class AdminAction extends BaseAction {
    17. // 注入Service 由于标签的存在 所以不需要getter setter
    18. @Autowired
    19. @Resource
    20. private AdminService adminService;
    21. // 管理员登录 1 验证用户名是否存在 2 验证密码是否正确
    22. @RequestMapping("login.action")
    23. public String login() {
    24. String username = this.getRequest().getParameter("username");
    25. String password = this.getRequest().getParameter("password");
    26. Admin adminEntity = new Admin();
    27. adminEntity.setUsername(username);
    28. List adminlist = this.adminService.getAdminByCond(adminEntity);
    29. if (adminlist.size() == 0) {
    30. this.getRequest().setAttribute("message", "用户名不存在");
    31. return "admin/index";
    32. } else {
    33. Admin admin = adminlist.get(0);
    34. if (password.equals(admin.getPassword())) {
    35. this.getSession().setAttribute("adminid", admin.getAdminid());
    36. this.getSession().setAttribute("adminname", admin.getUsername());
    37. this.getSession().setAttribute("realname", admin.getRealname());
    38. } else {
    39. this.getRequest().setAttribute("message", "密码错误");
    40. return "admin/index";
    41. }
    42. }
    43. return "admin/main";
    44. }
    45. // 修改密码
    46. @RequestMapping("editpwd.action")
    47. public String editpwd() {
    48. String adminid = (String) this.getSession().getAttribute("adminid");
    49. String password = this.getRequest().getParameter("password");
    50. String repassword = this.getRequest().getParameter("repassword");
    51. Admin admin = this.adminService.getAdminById(adminid);
    52. if (password.equals(admin.getPassword())) {
    53. admin.setPassword(repassword);
    54. this.adminService.updateAdmin(admin);
    55. } else {
    56. this.getRequest().setAttribute("message", "旧密码错误");
    57. }
    58. return "admin/editpwd";
    59. }
    60. // 管理员退出登录
    61. @RequestMapping("exit.action")
    62. public String exit() {
    63. this.getSession().removeAttribute("adminid");
    64. this.getSession().removeAttribute("adminname");
    65. this.getSession().removeAttribute("realname");
    66. return "admin/index";
    67. }
    68. // 准备添加数据
    69. @RequestMapping("createAdmin.action")
    70. public String createAdmin() {
    71. return "admin/addadmin";
    72. }
    73. // 添加数据
    74. @RequestMapping("addAdmin.action")
    75. public String addAdmin(Admin admin) {
    76. admin.setAddtime(VeDate.getStringDateShort());
    77. this.adminService.insertAdmin(admin);
    78. return "redirect:/admin/createAdmin.action";
    79. }
    80. // 通过主键删除数据
    81. @RequestMapping("deleteAdmin.action")
    82. public String deleteAdmin(String id) {
    83. this.adminService.deleteAdmin(id);
    84. return "redirect:/admin/getAllAdmin.action";
    85. }
    86. // 批量删除数据
    87. @RequestMapping("deleteAdminByIds.action")
    88. public String deleteAdminByIds() {
    89. String[] ids = this.getRequest().getParameterValues("adminid");
    90. for (String adminid : ids) {
    91. this.adminService.deleteAdmin(adminid);
    92. }
    93. return "redirect:/admin/getAllAdmin.action";
    94. }
    95. // 更新数据
    96. @RequestMapping("updateAdmin.action")
    97. public String updateAdmin(Admin admin) {
    98. this.adminService.updateAdmin(admin);
    99. return "redirect:/admin/getAllAdmin.action";
    100. }
    101. // 显示全部数据
    102. @RequestMapping("getAllAdmin.action")
    103. public String getAllAdmin(String number) {
    104. List adminList = this.adminService.getAllAdmin();
    105. PageHelper.getPage(adminList, "admin", null, null, 10, number, this.getRequest(), null);
    106. return "admin/listadmin";
    107. }
    108. // 按条件查询数据 (模糊查询)
    109. @RequestMapping("queryAdminByCond.action")
    110. public String queryAdminByCond(String cond, String name, String number) {
    111. Admin admin = new Admin();
    112. if (cond != null) {
    113. if ("username".equals(cond)) {
    114. admin.setUsername(name);
    115. }
    116. if ("password".equals(cond)) {
    117. admin.setPassword(name);
    118. }
    119. if ("realname".equals(cond)) {
    120. admin.setRealname(name);
    121. }
    122. if ("contact".equals(cond)) {
    123. admin.setContact(name);
    124. }
    125. if ("addtime".equals(cond)) {
    126. admin.setAddtime(name);
    127. }
    128. }
    129. List nameList = new ArrayList();
    130. List valueList = new ArrayList();
    131. nameList.add(cond);
    132. valueList.add(name);
    133. PageHelper.getPage(this.adminService.getAdminByLike(admin), "admin", nameList, valueList, 10, number, this.getRequest(), "query");
    134. name = null;
    135. cond = null;
    136. return "admin/queryadmin";
    137. }
    138. // 按主键查询数据
    139. @RequestMapping("getAdminById.action")
    140. public String getAdminById(String id) {
    141. Admin admin = this.adminService.getAdminById(id);
    142. this.getRequest().setAttribute("admin", admin);
    143. return "admin/editadmin";
    144. }
    145. public AdminService getAdminService() {
    146. return adminService;
    147. }
    148. public void setAdminService(AdminService adminService) {
    149. this.adminService = adminService;
    150. }
    151. }

    AjaxAction

    1. package com.action;
    2. import java.util.List;
    3. import javax.annotation.Resource;
    4. import org.json.JSONArray;
    5. import org.json.JSONException;
    6. import org.json.JSONObject;
    7. import org.springframework.beans.factory.annotation.Autowired;
    8. import org.springframework.stereotype.Controller;
    9. import org.springframework.web.bind.annotation.RequestMapping;
    10. import org.springframework.web.bind.annotation.ResponseBody;
    11. import com.entity.Peihuo;
    12. import com.service.PeihuoService;
    13. //定义为控制器
    14. @Controller
    15. // 设置路径
    16. @RequestMapping(value = "/ajax", produces = "text/plain;charset=utf-8")
    17. public class AjaxAction extends BaseAction {
    18. @Autowired
    19. @Resource
    20. private PeihuoService peihuoService;
    21. // 准备添加数据
    22. @RequestMapping("getPeihuo.action")
    23. @ResponseBody
    24. public String getPeihuo() throws JSONException {
    25. String cityid = this.getRequest().getParameter("cityid");
    26. Peihuo peihuo = new Peihuo();
    27. peihuo.setCityid(cityid);
    28. List peihuoList = this.peihuoService.getPeihuoByCond(peihuo);
    29. JSONArray peihuoid = new JSONArray(); // 存放ID
    30. JSONArray peihuoname = new JSONArray(); // 存放名称
    31. for (Peihuo c : peihuoList) {
    32. peihuoid.put(c.getPeihuoid());
    33. peihuoname.put(c.getPeihuoname());
    34. }
    35. JSONObject json = new JSONObject();
    36. json.put("peihuoid", peihuoid.toString().replaceAll("\"", ""));
    37. json.put("peihuoname", peihuoname.toString().replaceAll("\"", ""));
    38. System.out.println(json.toString());
    39. return json.toString();
    40. }
    41. }

    ArticleAction

    1. package com.action;
    2. import java.util.ArrayList;
    3. import java.util.List;
    4. import javax.annotation.Resource;
    5. import org.springframework.beans.factory.annotation.Autowired;
    6. import org.springframework.stereotype.Controller;
    7. import org.springframework.web.bind.annotation.RequestMapping;
    8. import com.entity.Article;
    9. import com.service.ArticleService;
    10. import com.util.PageHelper;
    11. import com.util.VeDate;
    12. //定义为控制器
    13. @Controller
    14. // 设置路径
    15. @RequestMapping(value = "/article", produces = "text/plain;charset=utf-8")
    16. public class ArticleAction extends BaseAction {
    17. // 注入Service 由于标签的存在 所以不需要getter setter
    18. @Autowired
    19. @Resource
    20. private ArticleService articleService;
    21. // 准备添加数据
    22. @RequestMapping("createArticle.action")
    23. public String createArticle() {
    24. return "admin/addarticle";
    25. }
    26. // 添加数据
    27. @RequestMapping("addArticle.action")
    28. public String addArticle(Article article) {
    29. article.setAddtime(VeDate.getStringDateShort());
    30. article.setHits("0");
    31. this.articleService.insertArticle(article);
    32. return "redirect:/article/createArticle.action";
    33. }
    34. // 通过主键删除数据
    35. @RequestMapping("deleteArticle.action")
    36. public String deleteArticle(String id) {
    37. this.articleService.deleteArticle(id);
    38. return "redirect:/article/getAllArticle.action";
    39. }
    40. // 批量删除数据
    41. @RequestMapping("deleteArticleByIds.action")
    42. public String deleteArticleByIds() {
    43. String[] ids = this.getRequest().getParameterValues("articleid");
    44. for (String articleid : ids) {
    45. this.articleService.deleteArticle(articleid);
    46. }
    47. return "redirect:/article/getAllArticle.action";
    48. }
    49. // 更新数据
    50. @RequestMapping("updateArticle.action")
    51. public String updateArticle(Article article) {
    52. this.articleService.updateArticle(article);
    53. return "redirect:/article/getAllArticle.action";
    54. }
    55. // 显示全部数据
    56. @RequestMapping("getAllArticle.action")
    57. public String getAllArticle(String number) {
    58. List
      articleList = this.articleService.getAllArticle();
    59. PageHelper.getPage(articleList, "article", null, null, 10, number, this.getRequest(), null);
    60. return "admin/listarticle";
    61. }
    62. // 按条件查询数据 (模糊查询)
    63. @RequestMapping("queryArticleByCond.action")
    64. public String queryArticleByCond(String cond, String name, String number) {
    65. Article article = new Article();
    66. if (cond != null) {
    67. if ("title".equals(cond)) {
    68. article.setTitle(name);
    69. }
    70. if ("image".equals(cond)) {
    71. article.setImage(name);
    72. }
    73. if ("contents".equals(cond)) {
    74. article.setContents(name);
    75. }
    76. if ("addtime".equals(cond)) {
    77. article.setAddtime(name);
    78. }
    79. if ("hits".equals(cond)) {
    80. article.setHits(name);
    81. }
    82. }
    83. List nameList = new ArrayList();
    84. List valueList = new ArrayList();
    85. nameList.add(cond);
    86. valueList.add(name);
    87. PageHelper.getPage(this.articleService.getArticleByLike(article), "article", nameList, valueList, 10, number, this.getRequest(),
    88. "query");
    89. name = null;
    90. cond = null;
    91. return "admin/queryarticle";
    92. }
    93. // 按主键查询数据
    94. @RequestMapping("getArticleById.action")
    95. public String getArticleById(String id) {
    96. Article article = this.articleService.getArticleById(id);
    97. this.getRequest().setAttribute("article", article);
    98. return "admin/editarticle";
    99. }
    100. public ArticleService getArticleService() {
    101. return articleService;
    102. }
    103. public void setArticleService(ArticleService articleService) {
    104. this.articleService = articleService;
    105. }
    106. }

    BaseAction

    1. package com.action;
    2. import java.io.IOException;
    3. import java.io.PrintWriter;
    4. import java.util.Map;
    5. import javax.servlet.http.HttpServletRequest;
    6. import javax.servlet.http.HttpServletResponse;
    7. import javax.servlet.http.HttpSession;
    8. import org.apache.commons.logging.Log;
    9. import org.apache.commons.logging.LogFactory;
    10. import org.json.JSONException;
    11. import org.json.JSONObject;
    12. import org.springframework.stereotype.Controller;
    13. import org.springframework.web.context.request.RequestContextHolder;
    14. import org.springframework.web.context.request.ServletRequestAttributes;
    15. /**
    16. * Action 基类
    17. */
    18. @Controller
    19. public class BaseAction {
    20. /* 日志 */
    21. protected final Log log = LogFactory.getLog(getClass());
    22. /* 获取基本环境 */
    23. public Map getParameters() {// 封装为Map的requestParameters
    24. ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    25. return attrs.getRequest().getParameterMap();
    26. }
    27. public HttpServletRequest getRequest() {
    28. ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    29. return attrs.getRequest();
    30. }
    31. public HttpSession getSession() {
    32. HttpSession session = null;
    33. try {
    34. session = this.getRequest().getSession();
    35. } catch (Exception e) {
    36. }
    37. return session;
    38. }
    39. /* 向客户端输出操作成功或失败信息 */
    40. public void writeJsonResponse(String success) throws IOException, JSONException {
    41. ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    42. HttpServletResponse response = attrs.getResponse();
    43. response.setContentType("text/json;charset=UTF-8");
    44. PrintWriter out = response.getWriter();
    45. // 将要被返回到客户端的对象
    46. JSONObject json = new JSONObject();
    47. json.accumulate("result", success);
    48. System.out.println(json.toString());
    49. out.println(json.toString());
    50. out.flush();
    51. out.close();
    52. }
    53. }

    如果也想学习本系统,下面领取。关注并回复:077ssm 

     

  • 相关阅读:
    flink技术总结待续
    springboot新冠疫苗预约系统在线视频点播系统毕业设计毕设作品开题报告开题答辩PPT
    sCrypt 中的 ECDSA 签名验证
    8.定义算法中的函数
    Skywalking
    【2019】【论文笔记】混合石墨烯等离子体光栅在THz下增强非线——
    iNFTnews | iPhone14已来,苹果的元宇宙还有多远?
    [ 漏洞复现篇 ] OpenSSH 命令注入漏洞 (CVE-2020-15778)
    Debian11.5设置静态IP 221021记录
    LINQ to SQL语句之ADO.NET与LINQ to SQL
  • 原文地址:https://blog.csdn.net/m0_74967853/article/details/128179170