Java项目:SSM网上药品销售商城网站系统

news/2025/2/11 14:47:32/

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

使用说明

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

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

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

3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,http://localhost:8080/
用户账号/密码: user/123456

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

运行截图

前台界面

后台界面

相关代码

管理员控制器

package com.shop.controller;import java.io.File;
import java.util.Date;
import java.util.List;//import javax.servlet.http.HttpServletRequest;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;import com.shop.Utils.PageBean;
import com.shop.Utils.UUIDUtiils;
import com.shop.po.Adminuser;
import com.shop.po.Category;
import com.shop.po.Categorysecond;
import com.shop.po.Message;
import com.shop.po.Orders;
import com.shop.po.Product;
import com.shop.po.User;
import com.shop.service.CategorySecondService;
import com.shop.service.CategoryService;
import com.shop.service.MessageService;
import com.shop.service.OrderService;
import com.shop.service.ProductService;
import com.shop.service.UserService;import javax.servlet.http.HttpServletRequest;@Controller
public class AdminController {@Autowiredprivate UserService userService;@Autowiredpublic CategoryService categoryService;@Autowiredpublic CategorySecondService categorySecondService;@Autowiredpublic ProductService productService;@Autowiredprivate OrderService orderService;@Autowiredprivate MessageService messageService;@RequestMapping("/admin/admin_findAll")public String admin_findAll(Model model, HttpServletRequest request) throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}List<User> userList = userService.admin_findAll();model.addAttribute("userList", userList);return "admin/user/list";}@RequestMapping("/admin/adminCategory_findAll")public String adminCategory_findAll(Model model, HttpServletRequest request)throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}List<Category> categoryList = categoryService.adminbFindCategory();/*for (Category category : categoryList) {System.out.println(category.getCname());}*/model.addAttribute("categoryList", categoryList);return "admin/category/list";}@RequestMapping("/admin/adminCategory_add")public String adminCategory_add(Model model,HttpServletRequest request) throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}
//		List<Category> categoryList = categoryService.adminbFindCategory();
//		model.addAttribute("categoryList", categoryList);return "admin/category/add";}@RequestMapping("/admin/adminCategory_save")public String adminCategory_save(@RequestParam String cname,HttpServletRequest request)throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}Category addCategory = new Category();addCategory.setCname(cname);categoryService.addCategory(addCategory);return "redirect:/admin/adminCategory_findAll.action";}@RequestMapping("/admin/adminCategory_edit")public String adminCategory_delete(@RequestParam int cid, Model model,HttpServletRequest request)throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}Category existCategory = categoryService.findCategory(cid);model.addAttribute("existCategory", existCategory);return "admin/category/edit";}@RequestMapping("/admin/adminCategory_update")public String adminCategory_update(@RequestParam int cid,@RequestParam String cname,HttpServletRequest request) {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}Category category = new Category();category.setCid(cid);category.setCname(cname);categoryService.adminCategory_update(category);return "redirect:/admin/adminCategory_findAll.action";}@RequestMapping("/admin/adminCategory_delete")public String adminCategory_delete(@RequestParam int cid,HttpServletRequest request) throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}categorySecondService.adminCategorySecond_deleteByCid(cid);categoryService.deleteCategoryByCid(cid);return "redirect:/admin/adminCategory_findAll.action";}// admin 的二级分类的管理@RequestMapping("/admin/adminCategorySecond_findAllByPage")public String adminCategorySecond_findAllByPage(@RequestParam int page,Model model,HttpServletRequest request) {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}PageBean<Categorysecond> csPageBean = categorySecondService.adminCategorySecond_findAllByPage(page);/*List<Categorysecond> list = csPageBean.getList();for (Categorysecond categorysecond : list) {System.out.println(categorysecond.getCsname());}*/model.addAttribute("csPageBean", csPageBean);return "admin/categorysecond/list";}@RequestMapping("admin/adminCategorySecond_addPage")public String adminCategorySecond_addPage(Model model,HttpServletRequest request) throws Exception{Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}List<Category> categoryList = categoryService.adminbFindCategory();model.addAttribute("categoryList", categoryList);return "admin/categorysecond/add";}@RequestMapping("admin/adminCategorySecond_save")public String adminCategorySecond_save(@RequestParam String csname,@RequestParam int cid,HttpServletRequest request) throws Exception{Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}Categorysecond categorysecond = new Categorysecond();categorysecond.setCsname(csname);categorysecond.setCid(cid);categorySecondService.adminCategorySecond_save(categorysecond);return "redirect:/admin/adminCategorySecond_findAllByPage.action?page=1";}@RequestMapping("admin/adminCategorySecond_edit")public String adminCategorySecond_edit(@RequestParam int csid,Model model,HttpServletRequest request) throws Exception{Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}Categorysecond findByCsid = categorySecondService.findByCsid(csid);model.addAttribute("findByCsid", findByCsid);return "admin/categorysecond/edit";}@RequestMapping("admin/adminCategorySecond_update")public String adminCategorySecond_update(@RequestParam String csname,@RequestParam int csid,HttpServletRequest request){Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}Categorysecond categorysecond = new Categorysecond();categorysecond.setCsname(csname);categorysecond.setCsid(csid);categorySecondService.adminCategorySecond_update(categorysecond);return "redirect:/admin/adminCategorySecond_findAllByPage.action?page=1";}@RequestMapping("admin/adminCategorySecond_delete")public String adminCategorySecond_delete(@RequestParam int csid,HttpServletRequest request) throws Exception{Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}categorySecondService.adminCategorySecond_delete(csid);return "redirect:/admin/adminCategorySecond_findAllByPage.action?page=1";}//admin的商品管理@RequestMapping("/admin/adminProduct_findAllByPage")public String adminProduct_findAllByPage(@RequestParam int page, Model model,HttpServletRequest request)throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}PageBean<Product> allProPageBean = productService.findAllProduct(page);model.addAttribute("allProPageBean", allProPageBean);return "admin/product/list";}@RequestMapping("/admin/adminProduct_addPage")public String adminProduct_addPage(Model model,HttpServletRequest request) throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}//查询出所有的二级分类List<Categorysecond> cslist = categorySecondService.findAll();/*for (Categorysecond categorysecond : cslist) {System.out.println(categorysecond.getCsname());}*/model.addAttribute("cslist", cslist);return "admin/product/add";}@RequestMapping("/admin/adminProduct_save")public String adminProduct_save(Product product,HttpServletRequest request,MultipartFile file) throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}product.setPdate(new Date());
//		上传图片if (file != null) {String path = request.getServletContext().getRealPath("/products");String uploadFileName = file.getOriginalFilename();String fileName = UUIDUtiils.getUUID()+uploadFileName;File diskFile = new File(path + "//" + fileName);file.transferTo(diskFile);product.setImage("products/" + fileName);}System.out.println(product.getImage());productService.adminProduct_save(product);return "redirect:/admin/adminProduct_findAllByPage.action?page=1";}@RequestMapping("admin/adminProduct_deletecs")public String adminProduct_deletecs(@RequestParam int pid,HttpServletRequest request) throws Exception{Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}productService.adminProduct_deletecs(pid);return "redirect:/admin/adminProduct_findAllByPage.action?page=1";}/*** 编辑商品* * @param pid* @param model* @param request* @return* @throws Exception*/@RequestMapping("admin/adminProduct_edit")public String adminProduct_edit(@RequestParam int pid,Model model,HttpServletRequest request) throws Exception{Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}Product product = productService.finbProductByPid(pid);model.addAttribute("findByPid", product);//查询出所有的二级分类List<Categorysecond> cslist = categorySecondService.findAll();model.addAttribute("cslist", cslist);return "admin/product/edit";}@RequestMapping("/admin/adminProduct_update")public String adminProduct_update(Product product,HttpServletRequest request,MultipartFile file) throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}product.setPdate(new Date());
//		上传图片if (file != null) {String path = request.getServletContext().getRealPath("/products");String uploadFileName = file.getOriginalFilename();String fileName = UUIDUtiils.getUUID()+uploadFileName;File diskFile = new File(path + "//" + fileName);file.transferTo(diskFile);product.setImage("products/" + fileName);}productService.adminProduct_update(product);return "redirect:/admin/adminProduct_findAllByPage.action?page=1";}/** 订单管理模块  **/@RequestMapping("/admin/adminOrder_findAllByPage")public String adminOrder_findAllByPage(@RequestParam int page, Model model,HttpServletRequest request)throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}PageBean<Orders> allProPageBean = orderService.findAllOrderByStateAndPage(page);model.addAttribute("pageBean", allProPageBean);return "admin/order/list";}//adminOrder_findByState@RequestMapping("/admin/adminOrder_findByState")public String adminOrder_findByState(@RequestParam int page,@RequestParam int state, Model model,HttpServletRequest request)throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}PageBean<Orders> allProPageBean = orderService.findAllOrderByStateAndPage(state,page);model.addAttribute("pageBean", allProPageBean);return "admin/order/list";}//订单详情//adminOrder_findOrderItem@RequestMapping("/admin/adminOrder_findOrderItem")public String adminOrder_findOrderItem(@RequestParam int oid, Model model,HttpServletRequest request)throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}Orders orderItems = orderService.findOrderByOid(oid);model.addAttribute("orderItems", orderItems);return "admin/order/list";}//更新订单状态@RequestMapping("/admin/adminOrder_updateState")public String adminOrder_updateState(@RequestParam int oid, @RequestParam int status, Model model,HttpServletRequest request)throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}orderService.updateOrderStatus(oid, status);return "redirect:/admin/adminOrder_findAllByPage.action?page=1";}//后台留言管理 @RequestMapping("/admin/adminMessage_findAllByPage")public String adminMessage_findAllByPage(@RequestParam int page, Model model,HttpServletRequest request)throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}PageBean<Message> pageBean = messageService.findAllMessageByPage(page);model.addAttribute("pageBean", pageBean);return "admin/message/list";}@RequestMapping("/admin/adminMessage_delete")public String adminOrder_updateState(@RequestParam int messageid, Model model,HttpServletRequest request)throws Exception {Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin");if(adminuserLogin==null){request.getSession().setAttribute("message","对不起您还没有登录");return "admin/index";}messageService.deleteMessage(messageid);return "redirect:/admin/adminMessage_findAllByPage.action?page=1";}}

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


http://www.ppmy.cn/news/4740.html

相关文章

Android 进阶——性能优化之电量优化全攻略及实战小结(一)

文章大纲引言一、偷懒至上的原则二、低电耗模式1、低电耗模式概述2、低电耗模式限制3、适配适应低电耗模式三、应用待机模式对其他用例的支持引言 电池续航时间是移动用户体验中最重要的一个方面。没电的设备完全无法使用。因此&#xff0c;对于应用来说&#xff0c;尽可能地考…

Java项目:SSM网上零食超市商城

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

非零基础自学Golang 第11章 文件操作 11.1 目录基本操作 11.1.2 创建目录 11.1.3 删除目录

非零基础自学Golang 文章目录非零基础自学Golang第11章 文件操作11.1 目录基本操作11.1.2 创建目录11.1.3 删除目录第11章 文件操作 11.1 目录基本操作 11.1.2 创建目录 Go标准库中的os库提供了平台无关性的操作系统功能接口。 创建目录时可以使用os库的如下接口&#xff1…

【Linux】shell命令以及运行原理

shell命令1.用户不能直接使用操作系统2.Linux是一个操作系统3.在软件层面操作Linux系统4.shell运行原理1.用户不能直接使用操作系统 首先在讲shell命令之前&#xff0c;我们要知道 “用户是不能直接在操作系统上操作的&#xff0c;只能在操作系统之上&#xff0c;也就是软件层面…

工程复现 -- SiamMOT

工程复现 – SiamMOT 先赞后看&#xff0c;养成好习惯&#xff0c;感谢您的理解与支持&#xff01; 参考&#xff1a; 1. siam-mot源码地址 2. SiamMOT 论文地址 3. SiamMOT 论文解析 简单介绍 SiamMOT&#xff08;SiamMOT: Siamese Multi-Object Tracking&#xff09;是…

juc-3-volatile

目录 1 多线程下变量的不可见性及解决方案 2 不可见性解决方案 2.1 加锁方式解决 2.2 使用volatile关键字 2.3 while(true)速度快调用本地线程内存&#xff0c;加延时即可访问主内存的共享变量 3 volatile不保证原子性以及解决方案 3.1 案例 volatile 验证不是原子性 3.…

Sentinel-1产品定义与产品格式(CSDN_0001_20220904)

&#xff08;文章编号&#xff1a;CSDN_0001_20220904&#xff09; 目录 1. 概述 1.1 地球物理测量 1.2 极化 1.3 干涉 2. 产品级别和产品类型 2.1 Level-0 2.2 Level-1 2.1.1 SLC 2.1.2 GRD 2.2 Level-2 3. 产品文件 3.1 组织结构 3.1.1 Annotation measuremen…

区块链入门的几个基本问题

目录前言比特币区块链区块链大揭秘抛砖引玉故事一故事二总结引人入胜侃侃而谈去中心化开放性不可篡改性相关技术共识机制共识机制的两大核心达成共识的主要过程&#xff08;产生新区块的过程&#xff09;工作量如何理解&#xff1f;Hash计算Bits和目标Hash值Merkle Root双花问题…