基于javaweb+mysql的ssm水果生鲜超市商城管理系统(java+ssm+jsp+jquery+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM水果生鲜超市商城管理系统(java+ssm+jsp+jquery+mysql)
项目介绍
该项目为前后台项目,分为普通用户与管理员两种角色,前台普通用户登录,后台管理员登录;
管理员角色包含以下功能: 管理员登录,用户管理,生鲜分类管理,生鲜商品管理,订单管理,用户留言管理等功能。
用户角色包含以下功能: 用户首页,用户登录注册,查看某个商品,加入购物车,确认订单,查看我的订单,查看留言板等功能。
环境需要
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项目:否;
技术栈
- 后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+jQuery+Ajax
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 登录
Cart cart=getCart(request);
cart.addCart(cartItem);
return "cart";
// 查看我的购物车
@RequestMapping("/myCart")
public String myCart(HttpServletRequest request,Model model){
User loginUser = (User) request.getSession().getAttribute("loginUser");
if (loginUser == null) {
model.addAttribute("message","您还没有登录!");
return "msg";
return "cart";
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());
}*/
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 (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{
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","对不起您还没有登录");
@Autowired
private 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";
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")
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";
@RequestMapping("/payOrder")
public String payOrder(Orders orders,@RequestParam String receiveInfo,@RequestParam String phoNum,@RequestParam String accepter) throws Exception {
orders.setReceiveinfo(receiveInfo);
orders.setPhonum(phoNum);
orders.setAccepter(accepter);
orderService.payOrder(orders);
return "redirect:myOrder.action?page=1";
//payOrderAganin
@RequestMapping("/payOrderAganin")
public String payOrderAganin(@RequestParam int oid,HttpServletRequest request){
Orders noPayOrder = orderService.findOrderByOid(oid);
request.getSession().setAttribute("orders", noPayOrder);
return "order";
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";
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);
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);
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","对不起您还没有登录");
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);
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());
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);
// 删除某个购物项
@RequestMapping("/delProFromCart")
public String delProFromCart(@RequestParam int pid,HttpServletRequest request){
Cart cart=getCart(request);
cart.delProFromCart(pid);
return "redirect:myCart.action";
public Cart getCart(HttpServletRequest request) {
Cart cart = (Cart) request.getSession().getAttribute("cart");
if (cart == null) {
cart = new Cart();
request.getSession().setAttribute("cart", cart);
return cart;