Java项目:23 基于SSM实现的在线购物商城系统

作者主页:源码空间codegym

简介:Java领域优质创作者、Java项目、学习资料、技术互助

文中获取源码

项目介绍

这是一个基于ssm框架的购物系统

  1. 该项目中有五个子模块。
  2. shop-manager模块负责导入该项目所需要的所有依赖包。
  3. shop-web模块负责存放前端代码以及项目的配置文件。
  4. shop-controller模块负责存放项目的控制器代码。
  5. shop-service模块负责存放项目的业务逻辑代码。
  6. shop-dao模块负责存放项目的mybatis数据库操作代码。

技术选型

运行环境:MySQL5.7+jdk1.8+Idea2020.3+Tomcat9

服务端技术:jsp+servlet+jdbc+jstl+el表达式

前端技术:bootstrap+jQuery+ajax

环境要求

1.运行环境:最好是java jdk1.8,我们在这个平台上运行的。其他版本理论上也可以。

2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;

3.tomcat环境:Tomcat7.x,8.X,9.x版本均可

4.硬件环境:windows7/8/10 4G内存以上;或者Mac OS;

5.是否Maven项目:是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven.项目

6.数据库:MySql5.7/8.0等版本均可;

技术栈

后台框架:servlet、MyBatis

数据库:MySQL

环境:JDK8、TOMCAT、IDEA

使用说明

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

2.使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目;

3.将项目中config-propertiesi配置文件中的数据库配置改为自己的配置,然后运行;

运行指导

idea导入源码空间站顶目教程说明(Vindows版)-ssm篇:

http://mtw.so/5MHvZq

源码地址:http://codegym.top

运行截图

前端界面

微信截图_20240222170001

微信截图_20240222170012

微信截图_20240222170052

微信截图_20240222170102

微信截图_20240222170111

微信截图_20240222165908

微信截图_20240222165928

微信截图_20240222165950

后台界面微信截图_20240222170133

微信截图_20240222170149

微信截图_20240222170159

代码

BackstageController

package com.zt.controller;

import com.zt.pojo.cart;
import com.zt.pojo.custom;
import com.zt.pojo.goods;
import com.zt.pojo.order;
import com.zt.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@Controller
public class BackstageController {
    @Resource
    private AdminService adminService;
    @Resource
    private GoodsService goodsService;
    @Resource
    private OrderService orderService;
    @Resource
    private CustomService customService;
    @Resource
    private CartService cartService;

    // 管理员后台界面跳转
    @RequestMapping(value = "/admin")
    public ModelAndView toBackstage(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("page/alogin.jsp");
        return modelAndView;
    }

    // 处理管理员登录
    @RequestMapping(value = "/alogin.action",method = RequestMethod.POST)
    public void alogin(@RequestParam(value = "cname") String cname,
                       @RequestParam(value = "password") String password,
                       HttpServletResponse response){
        PrintWriter out = null;
        try{
            out = response.getWriter();
            String result = adminService.loginService(cname,password);
            out.print(result);
            out.flush();
        }catch (IOException e){
            e.printStackTrace();
        }finally {}
        out.close();
    }

    // 添加商品信息
    @RequestMapping(value = "/addGoods.action",method = RequestMethod.POST)
    public void addGoods(@RequestParam(value = "id") String id,
                         @RequestParam(value = "img") String img,
                         @RequestParam(value = "title") String title,
                         @RequestParam(value = "info") String info,
                         @RequestParam(value = "name") String name,
                         @RequestParam(value = "price") String price,
                         @RequestParam(value = "stock") String stock,
                         @RequestParam(value = "para") String para,
                         @RequestParam(value = "type") String type,
                         @RequestParam(value = "weight") String weight,
                         HttpServletResponse response){
        PrintWriter out = null;
        try{
            out = response.getWriter();
            goods goods = new goods(id,img,title,info,name,new Integer(price),new Integer(stock),para,type,new Integer(weight));
            goodsService.addGoodsService(goods);
            out.print("success");
            out.flush();
        }catch (IOException e){
            e.printStackTrace();
        }finally {}
        out.close();
    }

    // 添加订单信息
    @RequestMapping(value = "/addOrder.action",method = RequestMethod.POST)
    public void addOrder(@RequestParam(value = "rid") String rid,
                         @RequestParam(value = "cname") String cname,
                         @RequestParam(value = "ids") String ids,
                         @RequestParam(value = "names") String names,
                         @RequestParam(value = "price") String price,
                         HttpServletResponse response){
        PrintWriter out = null;
        try{
            out = response.getWriter();
            order order = new order(rid,cname,ids,names,new Integer(price));
            orderService.addOrderService(order);
            out.print("success");
            out.flush();
        }catch (IOException e){
            e.printStackTrace();
        }finally {}
        out.close();
    }

    // 删除单个字段
    @RequestMapping(value = "/deleteItem.action",method = RequestMethod.POST)
    public void deleteItem1(@RequestParam("table") String table,
                            @RequestParam("id") String id,
                            HttpServletResponse response){
        PrintWriter out = null;
        try{
            out = response.getWriter();
            switch (table){
                case "custom":{
                    customService.deleteCustomService(id);
                    break;
                }
                case "goods":{
                    goodsService.deleteGoodsService(id);
                    break;
                }
                case "cart":{
                    String[] s = id.split("_");
                    cartService.deleteCartService(s[0],s[1]);
                    break;
                }
                case "order":{
                    orderService.deleteOrderService(id);
                    break;
                }
                default:break;
            }
            out.print("success");
            out.flush();
        }catch (IOException e){
            e.printStackTrace();
        }finally {}
        out.close();
    }

    // 修改客户信息
    @RequestMapping(value = "/updateCustom2.action",method = RequestMethod.POST)
    public void updateCustom2(@RequestParam(value = "cname") String cname,
                             @RequestParam(value = "name") String name,
                             @RequestParam(value = "phone") String phone,
                             @RequestParam(value = "address") String address,
                             @RequestParam(value = "password") String password,
                             @RequestParam(value = "question") String question,
                             @RequestParam(value = "answer") String answer,
                             HttpServletResponse response){
        PrintWriter out = null;
        try{
            out = response.getWriter();
            custom c = new custom(cname,password,name,phone,address,question,answer);
            customService.updateCustomService(c);
            out.print("success");
            out.flush();
        }catch (IOException e){
            e.printStackTrace();
        }finally {}
        out.close();
    }

    // 修改商品信息
    @RequestMapping(value = "/updateGoods.action",method = RequestMethod.POST)
    public void updateGoods(@RequestParam(value = "id") String id,
                            @RequestParam(value = "img") String img,
                            @RequestParam(value = "title") String title,
                            @RequestParam(value = "info") String info,
                            @RequestParam(value = "name") String name,
                            @RequestParam(value = "price") String price,
                            @RequestParam(value = "stock") String stock,
                            @RequestParam(value = "para") String para,
                            @RequestParam(value = "type") String type,
                            @RequestParam(value = "weight") String weight,
                            HttpServletResponse response){
        PrintWriter out = null;
        try{
            out = response.getWriter();
            goods goods = new goods(id,img,title,info,name,new Integer(price),new Integer(stock),para,type,new Integer(weight));
            goodsService.updateGoodsService(goods);
            out.print("success");
            out.flush();
        }catch (IOException e){
            e.printStackTrace();
        }finally {}
        out.close();
    }

    // 修改购物车信息
    @RequestMapping(value = "/updateCart.action",method = RequestMethod.POST)
    public void updateCart(@RequestParam(value = "cname") String cname,
                           @RequestParam(value = "id") String id,
                           @RequestParam(value = "img") String img,
                           @RequestParam(value = "name") String name,
                           @RequestParam(value = "price") String price,
                           @RequestParam(value = "number") String number,
                           HttpServletResponse response){
        PrintWriter out = null;
        try{
            out = response.getWriter();
            cart cart = new cart(cname,id,img,name,new Integer(price),new Integer(number));
            cartService.updateCartService(cart);
            out.print("success");
            out.flush();
        }catch (IOException e){
            e.printStackTrace();
        }finally {}
        out.close();
    }

    // 修改订单信息
    @RequestMapping(value = "/updateOrder.action",method = RequestMethod.POST)
    public void updateCart(@RequestParam(value = "rid") String rid,
                           @RequestParam(value = "cname") String cname,
                           @RequestParam(value = "ids") String ids,
                           @RequestParam(value = "names") String names,
                           @RequestParam(value = "price") String price,
                           HttpServletResponse response){
        PrintWriter out = null;
        try{
            out = response.getWriter();
            order order = new order(rid,cname,ids,names,new Integer(price));
            orderService.updateOrderService(order);
            out.print("success");
            out.flush();
        }catch (IOException e){
            e.printStackTrace();
        }finally {}
        out.close();
    }
}

  • 17
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
基于ssm的网上购物商城平台的设计与实现是一个复杂而关键的项目,需要深入的技术知识和丰富的前端,后端技术经验。该项目实现需要遵循以下步骤: 1.需求分析阶段:根据用户需求分析,形成项目需求文档,包括系统功能、系统架构、系统用户角色、数据模型等。 2.系统架构设计:设计系统架构,采用ssm框架实现,其中spring负责管理整个系统,mybatis负责数据持久化,spring MVC负责页面与控制器之间的交互。 3.数据库设计:根据系统的需求文档,设计和优化数据库架构,创建相应的数据表格。 4.前端设计:采用HTML5、CSS3、JavaScript等前端技术实现用户界面,并与后端系统进行整合和交互。 5.后端实现:使用Java编程语言实现系统的后端功能,包括数据访问、业务逻辑、用户验证、安全管理等。 6.测试阶段:对整个系统进行全面的测试,包括单元测试、功能测试、性能测试等。检测系统各项功能是否能够完整地运转。 7.上线运维:将系统部署到生产环境中,通过监控和维护确保系统的稳定运行。 综上所述,基于ssm的网上购物商城平台的设计与实现是一个复杂而综合性强的项目。需要掌握一定的前端、后端技术,具有较丰富的经验和扎实的程序开发基础。通过把握以上的步骤,能够顺利地完成开发工作,实现一款完整的网上商城平台。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值