作者主页:源码空间站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+Bootstrap
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/ssm_hzp_site/ 登录 
 注:Tomcat中配置项目路径必须为ssm_hzp_site
 用户账号/密码: user/123456
 管理员账号/密码:admin/admin
运行截图
前台界面





后台界面




代码相关
商品管理控制器
@Controller
@RequestMapping("/admin")
public class ProductController {
    @Autowired
    private ProductService productService;
    @Autowired
    private CategoryService categoryService;
    @Autowired
    private ProductImageService productImageService;
    @Autowired
    private PropertyValueService propertyValueService;
    @RequestMapping("/listProduct")
    public String findAll(Model model,Integer category_id) {
        List<Product> products = productService.findAll(category_id);
        model.addAttribute("products",products);
        Category category = categoryService.get(category_id);
        model.addAttribute("category",category);
        return "admin/listProduct";
    }
    @RequestMapping("/addProductView")
    public String addView(Model model,Integer category_id) {
        Category category = categoryService.get(category_id);
        model.addAttribute("category",category);
        return "admin/addProductView";
    }
    @RequestMapping("/addProduct")
    public String add(Product product) {
        productService.add(product);
        ProductImage productImage = new ProductImage();
        productImage.setProduct_id(product.getId());
        for(int i = 1;i <= 5 ;i++) {
            productImageService.add(productImage);
        }
        return "redirect:listProduct?category_id=" + product.getCategory_id();
    }
   /*  @RequestMapping("/deleteProduct")
   public String delete(Integer id,HttpServletRequest request) {
        productImageService.deleteByProductId(id);
        String path = request.getSession().getServletContext().getRealPath("" + id);
        deleteDir(new File(path));
        propertyValueService.deleteByProductId(id);
        int category_id = productService.get(id).getCategory_id();
        productService.delete(id);
        return "redirect:listProduct?category_id=" + category_id;
    }*/
/*    public static boolean deleteDir(File dir) {
        if(dir.isDirectory()){
            String[] children = dir.list();
            for(int i = 0 ;i < children.length;i++ ) {
                boolean success = deleteDir(new File(dir, children[i]));
                if(!success) {
                    return false;
                }
            }
        }
        return dir.delete();
    }*/
    @RequestMapping("/editProduct")
    public String edit(Integer id, Model model) {
        Product product = productService.get(id);
        model.addAttribute("product",product);
        Category category = categoryService.get(product.getCategory_id());
        model.addAttribute("category",category);
        return "admin/editProduct";
    }
    @RequestMapping("/updateProduct")
    public String update(Product product) {
        productService.update(product);
        return "redirect:listProduct?category_id=" + product.getCategory_id();
    }
}
属性管理控制器
@Controller
@RequestMapping("/admin")
public class PropertyValueController {
    @Autowired
    private PropertyValueService propertyValueService;
    @Autowired
    private PropertyService propertyService;
    @Autowired
    private ProductService productService;
    @RequestMapping("/listPropertyValue")
    public String findAll(Model model ,Integer product_id ,Integer category_id) {
        List<PropertyValue> propertyValues = propertyValueService.findByProductId(product_id);
        model.addAttribute("propertyValues",propertyValues);
        Product product = productService.get(product_id);
        model.addAttribute("product",product);
        List<Property> properties = propertyService.findAll(category_id);
        model.addAttribute("properties",properties);
        return "admin/listPropertyValue";
    }
    @RequestMapping("/addPropertyValueView")
    public String addPropertyValueView(Model model ,Integer product_id,Integer category_id) {
        List<PropertyValue> propertyValues = propertyValueService.findByProductId(product_id);
        model.addAttribute("propertiesValue",propertyValues);
        List<Property> properties = propertyService.findAll(category_id);
        model.addAttribute("properties",properties);
        Product product = productService.get(product_id);
        model.addAttribute("product",product);
        return "admin/addPropertyValueView";
    }
    @RequestMapping("/addPropertyValue")
    public String add(PropertyValue propertyValue ){
        int product_id = propertyValue.getProduct_id();
        int category_id = productService.get(product_id).getCategory_id();
        propertyValueService.add(propertyValue);
        return "redirect:listPropertyValue?product_id=" + product_id + "&category_id=" + category_id;
    }
    @RequestMapping("/deletePropertyValue")
    public String delete(Integer id)  {
        int product_id = propertyValueService.get(id).getProduct_id();
        int category_id = productService.get(product_id).getCategory_id();
        propertyValueService.delete(id);
        return "redirect:listPropertyValue?product_id=" + product_id + "&category_id=" + category_id;
    }
    @RequestMapping("/editPropertyValue")
    public String edit(Integer id ,Model model) {
        PropertyValue propertyValue = propertyValueService.get(id);
        model.addAttribute("propertyValue",propertyValue);
        Product product = productService.get(propertyValue.getProperty_id());
        model.addAttribute("product",product);
        return "admin/editPropertyValue";
    }
    @RequestMapping("/updatePropertyValue")
    public String update(PropertyValue propertyValue) {
        Integer product_id = propertyValue.getProduct_id();
        Integer category_id = productService.get(product_id).getCategory_id();
        propertyValueService.update(propertyValue);
        return "redirect:listPropertyValue?product_id=" + product_id + "&category_id=" + category_id;
    }
}
订单管理控制器
@Controller
@RequestMapping("/admin")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @RequestMapping("/listOrder")
    public String findAll(Model model) {
        List<Order> orders = orderService.findAll();
        model.addAttribute("orders",orders);
        return "admin/listOrder";
    }
    @RequestMapping("/updateOrder")
    public String update(Order order) {
        orderService.update(order);
        return "redirect:listOrder";
    }
    @RequestMapping("/orderDelivery")
    public String delivery(Integer order_id) {
        Order order = orderService.get(order_id);
        order.setDelivery_date(new Date());
        order.setStatus(OrderService.waitConfirm);
        orderService.update(order);
        return "redirect:listOrder";
    }
}
如果也想学习本系统,下面领取。关注并回复:102ssm




![[附源码]Python计算机毕业设计Django农村人居环境治理监管系统](https://img-blog.csdnimg.cn/e326e60577f246e5bee10b16a1a0eb8d.png)









![[附源码]Python计算机毕业设计Django失物招领微信小程序论文](https://img-blog.csdnimg.cn/1e5cc57c26204824a12f9cca3f170aab.png)




