——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM校园平台设计与实现(java+ssm+jsp+jquery+layui+mysql)
项目介绍
角色:管理员、学生,项目分为前后台
学生登陆系统后,可以查看首页,学校介绍、领导架构、联系我们、留言板,新闻资讯信息、师资力量、校园风光、我的、后台管理等功能
管理员登陆系统后,可以查看个人中心,轮播图信息,基础数据管理(班级管理、新闻资讯类型管理、生源地管理、所教专业管理、校园风光类型管理、院系管理),
留言板管理,新闻资讯信息管理,师资力量管理(师资力量管理、师资力量留言管理、师资力量收藏管理)、单页数据管理、
校园风光管理(校园风光管理、校园风光留言管理、校园风光收藏管理)、学生管理等功能,还能对每个功能逐一进行相应操作
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
6.数据库:MySql 5.7/8.0等版本均可;
技术栈
后端:SSM(Spring+SpringMVC+Mybatis)
前端:JSP+CSS+JS+JQUERY+Layui+elementUI
使用说明
使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行;
将项目中config.properties配置文件中的数据库配置改为自己的配置,然后运行;
运行项目,在浏览器中输入项目地址:
前台页面
http://localhost:8080/xueyuanwangzhan/front/
学生账户:a1 密码:123456
后台登录页面
http://localhost:8080/xueyuanwangzhan/jsp/login.jsp
管理员账户:admin 密码:admin
学生账户:a1 密码:123456
系统文档介绍:
新闻资讯展示页:
校园风光展示页:
学校介绍展示页:
留言板展示页:
新闻资讯信息展示:
我的信息展示页:
后台管理页面展示:
班级管理展示页:
院系管理展示页:
——————————CodeStart——————————
用户登录管理控制层:
public class LoginController extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
JSONObject jsonObject = new JSONObject();
String username = req.getParameter(“username”);
String password = req.getParameter(“password”);
resp.setCharacterEncoding(“UTF-8”);
HttpSession session = req.getSession();
if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
jsonObject.put(“code”, 2000);
jsonObject.put(“flag”, “fail”);
jsonObject.put(“user”, null);
jsonObject.put(“msg”, “usernameOrPasswordIsBank”);//用户名密码不能为空
resp.getWriter().print(jsonObject);
return;
password = MyMD5Util.encrypt(password);
System.out.println(password);
BusinessUserVO businessUserVO = new BusinessUserVO();
businessUserVO.setUsername(username);
businessUserVO.setPassword(password);
StudentUserVO studentUserVO = new StudentUserVO();
studentUserVO.setUsername(username);
studentUserVO.setPassword(password);
String flag1 = null;
String flag2 = null;
try {
flag1 = BusinessUserDao.selectUsername(businessUserVO);
if (“ok”.equals(flag1)) {//企业用户名存在
BusinessUserDTO businessUserDTO = BusinessUserDao.select(businessUserVO);
if (businessUserDTO != null) {
jsonObject.put(“code”, 2000);
jsonObject.put(“flag”, “success”);//登录成功
jsonObject.put(“user”, businessUserDTO);
jsonObject.put(“msg”, “login_success”);
session.setAttribute(“businessUser”,businessUserDTO);
resp.getWriter().print(jsonObject);
return;
} else {
jsonObject.put(“code”, 2000);
jsonObject.put(“flag”, “fail”);//登录失败
jsonObject.put(“user”, null);
jsonObject.put(“msg”, “passwordError”);//密码错误
resp.getWriter().print(jsonObject);
return;
flag2 = StudentUserDao.selectUsername(studentUserVO);
if (“ok”.equals(flag2)) {//学生用户名存在
StudentUser studentUser = StudentUserDao.select(studentUserVO);
if (studentUser != null) {
jsonObject.put(“code”, 2000);
jsonObject.put(“flag”, “success”);//登录成功
jsonObject.put(“user”, studentUser);
jsonObject.put(“msg”, “login_success”);
session.setAttribute(“studentUser”,studentUser);
resp.getWriter().print(jsonObject);
return;
} else {
jsonObject.put(“code”, 2000);
jsonObject.put(“flag”, “fail”);//登录失败
jsonObject.put(“user”, null);
jsonObject.put(“msg”, “passwordError”);//密码错误
resp.getWriter().print(jsonObject);
return;
//用户名不存在,前往注册
jsonObject.put(“code”, 2000);
jsonObject.put(“flag”, “fail”);//登录失败
jsonObject.put(“user”, null);
jsonObject.put(“msg”, “usernameIsNotExist”);//密码错误
resp.getWriter().print(jsonObject);
return;
} catch (SQLException throwables) {
throwables.printStackTrace();
return;
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
doGet(req, resp);
后台登录管理控制层:
public class AdminLoginController extends HttpServlet {
@SneakyThrows
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String username = req.getParameter(“username”);
String password = req.getParameter(“password”);
password = MyMD5Util.encrypt(password);
JSONObject jsonObject = new JSONObject();
HttpSession session = req.getSession();
Admin admin = new Admin(username, password);
Admin adminFromDB = AdminDao.findByUsernamePassword(admin);
if (adminFromDB!=null){
jsonObject.put(“code”,2000);
jsonObject.put(“msg”,”login_success”);
jsonObject.put(“admin”,adminFromDB.getUsername());
jsonObject.put(“flag”,”success”);
resp.getWriter().print(jsonObject);
session.setAttribute(“admin”,adminFromDB);
return;
}else {
jsonObject.put(“code”,2000);
jsonObject.put(“msg”,”no admin”);
jsonObject.put(“admin”,null);
jsonObject.put(“flag”,”fail”);
resp.getWriter().print(jsonObject);
return;
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doGet(req, resp);
用户管理控制层:
@Controller
@RequestMapping(value = “user”)
public class UserController {
private final GoodService goodService;
private final OrderService orderService;
private final ReviewService reviewService;
private final UserService userService;
private final CollectService collectService;
@Autowired
public UserController(GoodService goodService, OrderService orderService,
ReviewService reviewService, UserService userService,
CollectService collectService) {
this.goodService = goodService;
this.orderService = orderService;
this.reviewService = reviewService;
this.userService = userService;
this.collectService = collectService;
@RequestMapping(value = “userProfile”, method = RequestMethod.GET)
public String getMyProfile(ModelMap model, HttpSession session) {
User user = (User) session.getAttribute(“user”);
if (user == null) {
return “redirect:/“;
List
.getCollectByUserId(user.getId());
for (Collect collect : collects) {
collect.setGood(goodService.getGoodById(collect.getGoodId()));
List
List
List
List
List
model.addAttribute(“collects”, collects);
model.addAttribute(“goods”, goods);
model.addAttribute(“orders”, orders);
model.addAttribute(“reviews”, reviews);
model.addAttribute(“replies”, replies);
model.addAttribute(“sellGoods”, sellGoods);
return “user/userProfile”;
@RequestMapping(value = “/review”, method = RequestMethod.GET)
public String getReviewInfo(@RequestParam(required = false) Integer goodId,
@RequestParam(required = false) Integer reviewId) {
System.out.println(“reviewId” + reviewId);
if (reviewId != null) {
System.out.println(“reviewId” + reviewId);
if (reviewService.updateReviewStatus(1, reviewId) == 1) {
return “redirect:/goods/goodInfo?goodId=” + goodId;
return “redirect:/user/userProfile”;
@RequestMapping(value = “/reply”, method = RequestMethod.GET)
public String getReplyInfo(
@RequestParam(required = false) Integer reviewId,
@RequestParam(required = false) Integer replyId) {
if (replyId != null) {
if (reviewService.updateReplyStatus(1, replyId) == 1) {
Integer goodId = reviewService.getGoodIdByReviewId(reviewId);
return “redirect:/goods/goodInfo?goodId=” + goodId;
return “redirect:/user/userProfile”;
@RequestMapping(value = “/userEdit”, method = RequestMethod.GET)
public String getUserEdit(ModelMap model,
@RequestParam(value = “userId”, required = false) Integer userId,
HttpSession session) {
User sessionUser = (User) session.getAttribute(“user”);
if (sessionUser == null) {
return “redirect:/“;
User user = userService.getUserById(userId);
List
List
List
model.addAttribute(“user”, user);
model.addAttribute(“sellGoods”, sellGoods);
model.addAttribute(“reviews”, reviews);
model.addAttribute(“replies”, replies);
return “user/userEdit”;
@RequestMapping(value = “/userEdit”, method = RequestMethod.POST)
public String postUserEdit(ModelMap model, @Valid User user,
HttpSession session,
@RequestParam(value = “photo”, required = false) MultipartFile photo)
throws IOException {
String status;
Boolean insertSuccess;
User sessionUser = (User) session.getAttribute(“user”);
user.setId(sessionUser.getId());
InfoCheck infoCheck = new InfoCheck();
if (!infoCheck.isMobile(user.getMobile())) {
status = “请输入正确的手机号!”;
} else if (!infoCheck.isEmail(user.getEmail())) {
status = “请输入正确的邮箱!”;
} else if (userService.getUserByMobile(user.getMobile()).getId() != user
.getId()) {
System.out.println(userService.getUserByMobile(user.getMobile())
.getId() + “ “ + user.getId());
status = “此手机号码已使用!”;
} else if (userService.getUserByEmail(user.getEmail()).getId() != user
.getId()) {
status = “此邮箱已使用!”;
} else {
if (!photo.isEmpty()) {
RandomString randomString = new RandomString();
FileCheck fileCheck = new FileCheck();
String filePath = “/statics/image/photos/“ + user.getId();
String pathRoot = fileCheck.checkGoodFolderExist(filePath);
String fileName = user.getId()
- randomString.getRandomString(10);
String contentType = photo.getContentType();
String imageName = contentType.substring(contentType
.indexOf(“/“) + 1);
String name = fileName + “.” + imageName;
photo.transferTo(new File(pathRoot + name));
String photoUrl = filePath + “/“ + name;
user.setPhotoUrl(photoUrl);
} else {
String photoUrl = userService.getUserById(user.getId())
.getPhotoUrl();
user.setPhotoUrl(photoUrl);
insertSuccess = userService.updateUser(user);
if (insertSuccess) {
session.removeAttribute(“user”);
session.setAttribute(“user”, user);
return “redirect:/user/userProfile”;
} else {
status = “修改失败!”;
model.addAttribute(“user”, user);
model.addAttribute(“status”, status);
return “user/userEdit”;
System.out.println(user.getMobile());
System.out.println(status);
model.addAttribute(“user”, user);
model.addAttribute(“status”, status);
return “user/userEdit”;
@RequestMapping(value = “/password/edit”, method = RequestMethod.POST)
public ResponseEntity editPassword(@RequestBody Password password) {
User user = userService.getUserById(password.getUserId());
String oldPass = DigestUtils
.md5DigestAsHex((password.getOldPassword() + user.getCode())
.getBytes());
if (oldPass.equals(user.getPassword())) {
RandomString randomString = new RandomString();
String code = (randomString.getRandomString(5));
String md5Pass = DigestUtils.md5DigestAsHex((password
.getNewPassword() + code).getBytes());
Boolean success = userService.updatePassword(md5Pass, code,
password.getUserId());
if (success) {
return ResponseEntity.ok(true);
} else {
return ResponseEntity.ok(“密码修改失败!”);
} else {
return ResponseEntity.ok(“原密码输入不正确!”);
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=131524522608201oo
https://javayms.pages.dev?id=131524522608201oo