——————————DescriptionStart——————————
运行环境 Java≥8、MySQL≥5.7、Tomcat≥8
开发工具 eclipse/idea/myeclipse/sts等均可配置运行
适用 课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM在线农产品商城(java+ssm+jsp+bootstrap+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+bootstrap+jQuery
使用说明
使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ssm_zxncpshop 登录
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 HashMap map = new HashMap(); map.put("fid" , fid); map.put("sid" , sid); map.put("issj" , "yes" ); map.put("ph" , ph); map.put("saver" , shopid); map.put("leibie" , "购买商品" ); List<Product> nlist = productDAO.selectAll(map); PageHelper.startPage(pageNum,8 ); List<Product> list = productDAO.selectAll(map); PageInfo<Product> pageInfo = new PageInfo<Product>(list); request.setAttribute("pageInfo" , pageInfo); request.setAttribute("nlist" , nlist); request.setAttribute("sid" , sid); request.setAttribute("fid" , fid); request.setAttribute("shopid" , shopid); request.setAttribute("shop" , shop); String categroystr = "" ; if (sid!=null && !sid.equals("" )){ Category scategory = categoryDAO.findById(Integer.parseInt(sid)); categroystr=scategory.getName(); request.setAttribute("categroystr" , categroystr); } if (fid!=null && !fid.equals("" )){ Category fcategory = categoryDAO.findById(Integer.parseInt(fid)); categroystr=fcategory.getName(); request.setAttribute("categroystr" , categroystr); } saveobject.getCart(request); saveobject.getCategoryObject(request); return "shop" ; } @RequestMapping("loveRecommend") public String loveRecommend (@RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum,HttpServletRequest request) { Member member = (Member)request.getSession().getAttribute("sessionmember" ); List<Member> ulist = memberDAO.selectAll(null ); String[] uarray=new String[ulist.size()]; for (int i=0 ;i<ulist.size();i++){ uarray[i]=String.valueOf(ulist.get(i).getId());
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 bbs.setNote(note); bbs.setSavetime(Info.getDateStr()); bbs.setMid(member.getId()); bbsDAO.add(bbs); saveobject.getCart(request); saveobject.getCategoryObject(request); return "redirect:bbsShow.do?id=" +fid; } } package com.controller;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 @RequestMapping("fubiLb") public String fubiLb (@RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum,HttpServletRequest request) { HashMap map = new HashMap(); map.put("issj" , "yes" ); map.put("leibie" , "积分商品" ); List<Product> nlist = productDAO.selectAll(map); request.setAttribute("nlist" , nlist); PageHelper.startPage(pageNum,10 ); List<Product> list = productDAO.selectAll(map); PageInfo<Product> pageInfo = new PageInfo<Product>(list); request.setAttribute("pageInfo" , pageInfo); saveobject.getCart(request); saveobject.getCategoryObject(request); return "fubilb" ; } @RequestMapping("admin/udateIstj") public String udateIstj (HttpServletRequest request) { String id = request.getParameter("id" ); String istj = request.getParameter("type" ); String shop = request.getParameter("shop" ); Product product = productDAO.findById(Integer.parseInt(id)); product.setIstj(istj); productDAO.update(product); return "redirect:productMsg.do" ; } @RequestMapping("admin/udateIssj") public String udateIssj (HttpServletRequest request) { String id = request.getParameter("id" ); String shop = request.getParameter("shop" ); Product product = productDAO.findById(Integer.parseInt(id)); if (product.getIssj().equals("yes" )){ product.setIssj("no" ); }else { product.setIssj("yes" ); } productDAO.update(product); return "redirect:productMsg.do" ;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 } catch (RowsExceededException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (WriteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } try { //从内存中写入文件中 wwb.write(); //关闭资源,释放内存 wwb.close(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } try { response.sendRedirect("/vehiclemanagementsys/upload?filename=" + fileName.substring(fileName.lastIndexOf("/") + 1)); } catch (IOException e) { e.printStackTrace(); } } public static String getcheckbox(String name, String tablename, String zdname, String where) { String checkbox = ""; for (HashMap permap : new CommDAO().select("select * from " + tablename + " where " + where + " order by id desc")) { String optionstr = ""; for (String str : zdname.split(";")) { String zdstr = str.split("~")[0]; String zdnamestr = str.split("~")[1].equals("无名") ? "" : (str.split("~")[1] + ":"); optionstr += zdnamestr + permap.get(zdstr) + " - "; } if (optionstr.length() > 0) optionstr = optionstr.substring(0, optionstr.length() - 3); checkbox += "<label > <input type ='checkbox' name ='" + name + "' value =\ "" + optionstr + "\"> " + optionstr + "</label > \n"; } checkbox += "<input type =hidden name ='" + name + "' value ='' /> "; return checkbox; } public static String getcheckboxDk(String name, String tablename, String zdname, String nstr, String where) { String checkbox = ""; int i = 0; for (HashMap permap : new CommDAO().select("select * from " + tablename + " where " + where + " order by id desc")) {
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 } map.put("leibie" , "购买商品" ); PageHelper.startPage(pageNum,10 ); List<Product> list = productDAO.selectAll(map); for (Product product:list){ Category fcategory = categoryDAO.findById(Integer.parseInt(product.getFid())); Category scategory = categoryDAO.findById(Integer.parseInt(product.getSid())); product.setFcategory(fcategory); product.setScategory(scategory); } PageInfo<Product> pageInfo = new PageInfo<Product>(list); request.setAttribute("key" , key); request.setAttribute("fid" , fid); request.setAttribute("sid" , sid); request.setAttribute("pageInfo" , pageInfo); request.setAttribute("fcategorylist" , fcategorylist); saveobject.getCategoryObject(request); return "admin/productmsg" ; } @RequestMapping("/admin/categorySelect") public String categorySelect (HttpServletRequest request) { HashMap map = new HashMap(); List<Category> list = categoryDAO.selectFcategory(map); for (Category category:list){ List<Category> scategorylist = categoryDAO.selectScategory(category.getId()); category.setScategorylist(scategorylist); } request.setAttribute("list" , list); return "admin/productadd" ; } @RequestMapping("admin/productAdd") public String productAdd (Product product,HttpServletRequest request) { User user = (User)request.getSession().getAttribute("admin" ); String productno = Info.getAutoId(); product.setProductno(productno); product.setSaver(String.valueOf(user.getId())); product.setIssj("no" ); product.setIstj("no" ); product.setProductid("-1" ); product.setDelstatus("0" ); productDAO.add(product); return "redirect:productMsg.do" ; } @RequestMapping("admin/showFubi") public String showFubi (int id,HttpServletRequest request) { Product product = productDAO.findById(id);
——————————PayStart——————————
项目链接: https://javayms.github.io?id=232122102205200ls https://javayms.pages.dev?id=232122102205200ls