Java项目:SSM游戏点评网站

news2024/9/21 16:32:28

作者主页:源码空间站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

package com.action;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.entity.Admin;
import com.service.AdminService;
import com.util.PageHelper;
import com.util.VeDate;

//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/admin", produces = "text/plain;charset=utf-8")
public class AdminAction extends BaseAction {
	// 注入Service 由于标签的存在 所以不需要getter setter
	@Autowired
	@Resource
	private AdminService adminService;

	// 管理员登录 1 验证用户名是否存在 2 验证密码是否正确
	@RequestMapping("login.action")
	public String login() {
		String username = this.getRequest().getParameter("username");
		String password = this.getRequest().getParameter("password");
		Admin adminEntity = new Admin();
		adminEntity.setUsername(username);
		List<Admin> adminlist = this.adminService.getAdminByCond(adminEntity);
		if (adminlist.size() == 0) {
			this.getRequest().setAttribute("message", "用户名不存在");
			return "admin/index";
		} else {
			Admin admin = adminlist.get(0);
			if (password.equals(admin.getPassword())) {
				this.getSession().setAttribute("adminid", admin.getAdminid());
				this.getSession().setAttribute("adminname", admin.getUsername());
				this.getSession().setAttribute("realname", admin.getRealname());
			} else {
				this.getRequest().setAttribute("message", "密码错误");
				return "admin/index";
			}
		}
		return "admin/main";
	}

	// 修改密码
	@RequestMapping("editpwd.action")
	public String editpwd() {
		String adminid = (String) this.getSession().getAttribute("adminid");
		String password = this.getRequest().getParameter("password");
		String repassword = this.getRequest().getParameter("repassword");
		Admin admin = this.adminService.getAdminById(adminid);
		if (password.equals(admin.getPassword())) {
			admin.setPassword(repassword);
			this.adminService.updateAdmin(admin);
		} else {
			this.getRequest().setAttribute("message", "旧密码错误");
		}
		return "admin/editpwd";
	}

	// 管理员退出登录
	@RequestMapping("exit.action")
	public String exit() {
		this.getSession().removeAttribute("adminid");
		this.getSession().removeAttribute("adminname");
		this.getSession().removeAttribute("realname");
		return "admin/index";
	}

	// 准备添加数据
	@RequestMapping("createAdmin.action")
	public String createAdmin() {
		return "admin/addadmin";
	}

	// 添加数据
	@RequestMapping("addAdmin.action")
	public String addAdmin(Admin admin) {
		admin.setAddtime(VeDate.getStringDateShort());
		this.adminService.insertAdmin(admin);
		return "redirect:/admin/createAdmin.action";
	}

	// 通过主键删除数据
	@RequestMapping("deleteAdmin.action")
	public String deleteAdmin(String id) {
		this.adminService.deleteAdmin(id);
		return "redirect:/admin/getAllAdmin.action";
	}

	// 批量删除数据
	@RequestMapping("deleteAdminByIds.action")
	public String deleteAdminByIds() {
		String[] ids = this.getRequest().getParameterValues("adminid");
		for (String adminid : ids) {
			this.adminService.deleteAdmin(adminid);
		}
		return "redirect:/admin/getAllAdmin.action";
	}

	// 更新数据
	@RequestMapping("updateAdmin.action")
	public String updateAdmin(Admin admin) {
		this.adminService.updateAdmin(admin);
		return "redirect:/admin/getAllAdmin.action";
	}

	// 显示全部数据
	@RequestMapping("getAllAdmin.action")
	public String getAllAdmin(String number) {
		List<Admin> adminList = this.adminService.getAllAdmin();
		PageHelper.getPage(adminList, "admin", null, null, 10, number, this.getRequest(), null);
		return "admin/listadmin";
	}

	// 按条件查询数据 (模糊查询)
	@RequestMapping("queryAdminByCond.action")
	public String queryAdminByCond(String cond, String name, String number) {
		Admin admin = new Admin();
		if (cond != null) {
			if ("username".equals(cond)) {
				admin.setUsername(name);
			}
			if ("password".equals(cond)) {
				admin.setPassword(name);
			}
			if ("realname".equals(cond)) {
				admin.setRealname(name);
			}
			if ("contact".equals(cond)) {
				admin.setContact(name);
			}
			if ("addtime".equals(cond)) {
				admin.setAddtime(name);
			}
		}

		List<String> nameList = new ArrayList<String>();
		List<String> valueList = new ArrayList<String>();
		nameList.add(cond);
		valueList.add(name);
		PageHelper.getPage(this.adminService.getAdminByLike(admin), "admin", nameList, valueList, 10, number, this.getRequest(), "query");
		name = null;
		cond = null;
		return "admin/queryadmin";
	}

	// 按主键查询数据
	@RequestMapping("getAdminById.action")
	public String getAdminById(String id) {
		Admin admin = this.adminService.getAdminById(id);
		this.getRequest().setAttribute("admin", admin);
		return "admin/editadmin";
	}

	public AdminService getAdminService() {
		return adminService;
	}

	public void setAdminService(AdminService adminService) {
		this.adminService = adminService;
	}

}

AjaxAction

package com.action;

import java.util.List;

import javax.annotation.Resource;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.entity.Peihuo;
import com.service.PeihuoService;

//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/ajax", produces = "text/plain;charset=utf-8")
public class AjaxAction extends BaseAction {

	@Autowired
	@Resource
	private PeihuoService peihuoService;

	// 准备添加数据
	@RequestMapping("getPeihuo.action")
	@ResponseBody
	public String getPeihuo() throws JSONException {
		String cityid = this.getRequest().getParameter("cityid");
		Peihuo peihuo = new Peihuo();
		peihuo.setCityid(cityid);
		List<Peihuo> peihuoList = this.peihuoService.getPeihuoByCond(peihuo);
		JSONArray peihuoid = new JSONArray(); // 存放ID
		JSONArray peihuoname = new JSONArray(); // 存放名称
		for (Peihuo c : peihuoList) {
			peihuoid.put(c.getPeihuoid());
			peihuoname.put(c.getPeihuoname());
		}
		JSONObject json = new JSONObject();
		json.put("peihuoid", peihuoid.toString().replaceAll("\"", ""));
		json.put("peihuoname", peihuoname.toString().replaceAll("\"", ""));
		System.out.println(json.toString());
		return json.toString();
	}

}

ArticleAction

package com.action;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.entity.Article;
import com.service.ArticleService;
import com.util.PageHelper;
import com.util.VeDate;

//定义为控制器
@Controller
// 设置路径
@RequestMapping(value = "/article", produces = "text/plain;charset=utf-8")
public class ArticleAction extends BaseAction {
	// 注入Service 由于标签的存在 所以不需要getter setter
	@Autowired
	@Resource
	private ArticleService articleService;

	// 准备添加数据
	@RequestMapping("createArticle.action")
	public String createArticle() {
		return "admin/addarticle";
	}

	// 添加数据
	@RequestMapping("addArticle.action")
	public String addArticle(Article article) {
		article.setAddtime(VeDate.getStringDateShort());
		article.setHits("0");
		this.articleService.insertArticle(article);
		return "redirect:/article/createArticle.action";
	}

	// 通过主键删除数据
	@RequestMapping("deleteArticle.action")
	public String deleteArticle(String id) {
		this.articleService.deleteArticle(id);
		return "redirect:/article/getAllArticle.action";
	}

	// 批量删除数据
	@RequestMapping("deleteArticleByIds.action")
	public String deleteArticleByIds() {
		String[] ids = this.getRequest().getParameterValues("articleid");
		for (String articleid : ids) {
			this.articleService.deleteArticle(articleid);
		}
		return "redirect:/article/getAllArticle.action";
	}

	// 更新数据
	@RequestMapping("updateArticle.action")
	public String updateArticle(Article article) {
		this.articleService.updateArticle(article);
		return "redirect:/article/getAllArticle.action";
	}

	// 显示全部数据
	@RequestMapping("getAllArticle.action")
	public String getAllArticle(String number) {
		List<Article> articleList = this.articleService.getAllArticle();
		PageHelper.getPage(articleList, "article", null, null, 10, number, this.getRequest(), null);
		return "admin/listarticle";
	}

	// 按条件查询数据 (模糊查询)
	@RequestMapping("queryArticleByCond.action")
	public String queryArticleByCond(String cond, String name, String number) {
		Article article = new Article();
		if (cond != null) {
			if ("title".equals(cond)) {
				article.setTitle(name);
			}
			if ("image".equals(cond)) {
				article.setImage(name);
			}
			if ("contents".equals(cond)) {
				article.setContents(name);
			}
			if ("addtime".equals(cond)) {
				article.setAddtime(name);
			}
			if ("hits".equals(cond)) {
				article.setHits(name);
			}
		}

		List<String> nameList = new ArrayList<String>();
		List<String> valueList = new ArrayList<String>();
		nameList.add(cond);
		valueList.add(name);
		PageHelper.getPage(this.articleService.getArticleByLike(article), "article", nameList, valueList, 10, number, this.getRequest(),
				"query");
		name = null;
		cond = null;
		return "admin/queryarticle";
	}

	// 按主键查询数据
	@RequestMapping("getArticleById.action")
	public String getArticleById(String id) {
		Article article = this.articleService.getArticleById(id);
		this.getRequest().setAttribute("article", article);
		return "admin/editarticle";
	}

	public ArticleService getArticleService() {
		return articleService;
	}

	public void setArticleService(ArticleService articleService) {
		this.articleService = articleService;
	}

}

BaseAction

package com.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * Action 基类
 */
@Controller
public class BaseAction {

	/* 日志 */
	protected final Log log = LogFactory.getLog(getClass());

	/* 获取基本环境 */
	public Map<String, String[]> getParameters() {// 封装为Map的requestParameters
		ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
		return attrs.getRequest().getParameterMap();
	}

	public HttpServletRequest getRequest() {
		ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
		return attrs.getRequest();
	}

	public HttpSession getSession() {
		HttpSession session = null;
		try {
			session = this.getRequest().getSession();
		} catch (Exception e) {
		}
		return session;
	}

	/* 向客户端输出操作成功或失败信息 */
	public void writeJsonResponse(String success) throws IOException, JSONException {
		ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
		HttpServletResponse response = attrs.getResponse();
		response.setContentType("text/json;charset=UTF-8");
		PrintWriter out = response.getWriter();
		// 将要被返回到客户端的对象
		JSONObject json = new JSONObject();
		json.accumulate("result", success);
		System.out.println(json.toString());
		out.println(json.toString());
		out.flush();
		out.close();
	}
}

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

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/61690.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

jenkins-pipeline语法总结(最全)

1、jenkins总结之pipeline语法 jenkins总结之pipeline语法1、jenkins总结之pipeline语法1.1必要的Groovy知识1.2pipeline的组成1.2.1pipeline最简结构1.3post部分1.4pipeline支持的指令• environment&#xff1a;• tools&#xff1a;• input&#xff1a;• options&#xff…

大学网课查题接口

大学网课查题接口 本平台优点&#xff1a; 多题库查题、独立后台、响应速度快、全网平台可查、功能最全&#xff01; 1.想要给自己的公众号获得查题接口&#xff0c;只需要两步&#xff01; 2.题库&#xff1a; 查题校园题库&#xff1a;查题校园题库后台&#xff08;点击跳…

项目管理逻辑:老板为什么赔钱的项目也做?为什么害怕你闲着?

目录 1.波士顿矩阵 2.为什么企业还要做没有市场占有率,也没有销售增长率的产品? 2.1项目层级划分 2.2项目集 2.3组合管理 2.4赔钱也做的项目案例 1.波士顿矩阵 项目经理没有资源, 公司不给足够的支持 在任何一个企业老板的脑子里,都会有这样一个矩阵, 纵向表示销售增长…

数据结构与算法,MySQL数据库面试专题及答案

文章目录数据结构面试题及答案数组问题字符串相关问题链表问题二叉树问题编程面试问题之杂项答案数据结构与算法时间复杂度 并不是计算程序具体运行的时间&#xff0c;而是算法执行语句的次数 O(2^n) 表示对 n 数据处理需要进行 2^n 次计算 多项式的时间复杂度 数据 n 在表达式…

Docker安装部署Redis集群

目录 概述 一、创建文件和目录 1.1 创建需要挂载的文件和目录 1.2 同步操作 二、随机从节点模式 2.1 创建master节点的redis容器 2.2 在同一台机器上创建另外2个节点 2.3 其他2台机器同步操作 2.4 配置主从集群 2.4.1 进入任意一个 Redis 实例 2.4.2 配置集群 2.4…

《未来简史:从智人到智神》笔记一——人类的新议题

目录 一、人类的旧议题演变 二、人类的新议题 1、长生不死 2、追求幸福快乐 3、努力把自己升级为神 三、研究历史的意义——不是为了重复过去&#xff0c;而是为了摆脱过去并从中获得解放 四、生命的意义 1、主观体验有两个基本特征 2、生命的意义&#xff1f; 一、人类…

C语言第十三课:初阶指针

目录 前言&#xff1a; 一、指针是什么&#xff1a; 1.那么指针到底是什么呢&#xff1f; 2.内存中的数据存储原理&#xff1a; 3.数据存储与指针使用实例&#xff1a; 4.存储编址原理&#xff1a; 二、指针和指针类型&#xff1a; 1.决定了指针的步长&#xff1a; 2.决定了…

【VSCode + Anaconda】VSCode [WinError 126]找不到指定模块

【VSCode Anaconda】VSCode [WinError 126]找不到指定模块问题解决一解决二问题 在 Anaconda Prompt 中的 python 环境测试&#xff0c;可以使用 import torch 命令 现在在 VSCode 中测试&#xff0c;发现相关异常 图中&#xff0c;已经选择了相应的 conda 环境的 python.exe…

分片集群中的分片集合

分片集群中的分片集合 MongoDB 中 分片集群有专门推荐的模式&#xff0c;例如 分片集合 它是一种基于分片键的逻辑对文档进行分组&#xff0c;分片键的选择对分片是非常重要的&#xff0c;分片键一旦确定&#xff0c;MongoDB 对数据的分片对应用是透明的 mongodb 分片中&#…

MySQL高级语句(三)

一、正则表达式&#xff08;REGEXP&#xff09; 1、正则表达式匹配符 字符解释举列^匹配文本的开始字符’ ^aa ’ 匹配以 aa 开头的字符串$匹配文本的结束字符’ aa$ ’ 匹配以aa结尾的字符串.匹配任何单个字符’ a.b 匹配任何a和b之间有一个字符的字符串*匹配零个或多个在它…

数据结构—树、有序二叉树

文章目录树的概述树的分类二叉树的遍历有序二叉树代码通过链表方式构建有序二叉树通过递归方式实现有序二叉树递归遍历有序二叉树中序遍历&#xff1a;先序遍历&#xff1a;后序遍历&#xff1a;删除节点1、删除叶子节点删除叶子节点总结图示2、删除只有一个子树的节点删除只有…

毕业设计-基于深度学习火灾烟雾检测识别系统-yolo

前言 &#x1f4c5;大四是整个大学期间最忙碌的时光,一边要忙着准备考研,考公,考教资或者实习为毕业后面临的就业升学做准备,一边要为毕业设计耗费大量精力。近几年各个学校要求的毕设项目越来越难,有不少课题是研究生级别难度的,对本科同学来说是充满挑战。为帮助大家顺利通过…

Spring循环依赖源码解析(深度理解)

文章目录前言本章目标一、什么是循环依赖&#xff1f;1、那么循环依赖是个问题吗&#xff1f;2、但是在Spring中循环依赖就是一个问题了&#xff0c;为什么&#xff1f;二、Bean的生命周期2.1、在Spring中&#xff0c;Bean是如何生成的&#xff1f;2.2、那么这个注入过程是怎样…

GitLab CI/CD系列教程(一)

来自&#xff1a;GitLab CI/CD系列教程&#xff08;一&#xff09;&#xff1a;Docker安装GitLab_哔哩哔哩_bilibili 1. 创建虚拟机并连接Xterm 创建一个4G内存的虚拟机&#xff0c;否则很容易启动不了&#xff0c;报502 虚拟机的创建看这篇&#xff1a; VMware16的安装及VM…

基于java+ssm+vue+mysql的网上书店

项目介绍 本网上系统是针对目前网上的实际需求&#xff0c;从实际工作出发&#xff0c;对过去的网上系统存在的问题进行分析&#xff0c;结合计算机系统的结构、概念、模型、原理、方法&#xff0c;在计算机各种优势的情况下&#xff0c;采用目前最流行的B/S结构和java中流行的…

从0开始搭建vue2管理后台基础模板

网站主要完成&#xff1a;侧边菜单栏、页面标签卡、内容栏 源代码gitee地址&#xff1a;https://gitee.com/zhao_liangliang1997/navigation-bar 一、起步 1、创建vue项目 vue create 项目名2、引入element 3、其他安装 1、首先需要安装如下 cnpm install vuex cnpm install…

DockerCompose安装、使用 及 微服务部署实操

1 什么是DockerCompose DockerCompose是基于Compose文件帮助我们快速的部署分布式应用。 解决容器需手动一个个创建和运行的问题&#xff01; DockerCompose本质上也是一个文本文件&#xff0c;其通过指令定义集群中的每个容器如何运行。我们可以将其看做是将多个docker run…

Ansible 自动化运维工具的使用

目录 一、Ansible简介 二、Ansible 的安装和使用 1.下载 2.使用 三、Ansible命令和模块 1.命令格式 2.命令行模块 &#xff08;1&#xff09;command 模块 &#xff08;2&#xff09;shell 模块 &#xff08;3&#xff09;cron 模块 &#xff08;4&#xff09;user …

多线程 3

多线程 3 : 文章目录1.线程安全2. 产生线程安全的原因3. synchronized - 加锁操作4.可重入5.死锁问题6. volatile 关键字7.wait 和 notify1.线程安全 为啥会出现线程安全 &#xff1f;   罪魁祸首&#xff0c;还是多线程的抢占式执行&#xff0c; 正因为抢占式执行&#xff0c…

Java项目:SSM场地预订管理系统

作者主页&#xff1a;源码空间站2022 简介&#xff1a;Java领域优质创作者、Java项目、学习资料、技术互助 文末获取源码 项目介绍 本项目分为前后台&#xff0c;前台为普通用户登录&#xff0c;后台为管理员登录&#xff1b; 用户角色包含以下功能&#xff1a; 按分类查看场…