——————————DescriptionStart——————————
运行环境 Java≥8、MySQL≥5.7、Tomcat≥8
开发工具 eclipse/idea/myeclipse/sts等均可配置运行
适用 课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM饰品商城系统(java+ssm+jsp+javascript+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.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目; 6.数据库:MySql 5.7等版本均可;
技术栈
后端:Spring+springmvc+mybatis
前端:JSP+css+javascript+jQuery
使用说明
使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2.使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat 3. 将项目中config/jdbc.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080/ 登录
——————————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 User user = userService.loginFindByid(username); if (user!=null ) { response.getWriter().write("已经被注册" ); }else { response.getWriter().write("可以注册" ); } } catch (Exception e) { e.printStackTrace(); } } } package com.shop.controller;@Controller public class CategorySecondController { @Autowired private ProductService productService; @RequestMapping("/findCategorySecond") public String findCategorySecond (HttpServletRequest request,@RequestParam int cid,Model model,@RequestParam int page) throws Exception { request.getSession().setAttribute("cid" ,cid); PageBean<Product> proPageBean = productService.findProductyBycid(cid,page); model.addAttribute("pageBean" ,proPageBean); return "category" ; } @RequestMapping("/findCategorySecond1") public String findCategorySecond1 (@RequestParam int csid,Model model,@RequestParam int page) { PageBean<Product> proPageBean = productService.finbProductByCsid(csid,page);
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 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" ; } @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());
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 }*/ return true ; } @Override public void postHandle (HttpServletRequest request, HttpServletResponse response, Object arg2, ModelAndView arg3) throws Exception { } @Override public void afterCompletion (HttpServletRequest request, HttpServletResponse arg1, Object arg2, Exception arg3) throws Exception { } } package com.shop.util;@Controller public class PrivilageInterceptor implements HandlerInterceptor { @Override public boolean preHandle (HttpServletRequest request, HttpServletResponse response, Object object) throws Exception { String uri = request.getRequestURI(); if (uri.indexOf("admin.action" )>=0 ){ return true ; } Adminuser adminuserLogin = (Adminuser) request.getSession().getAttribute("adminuserLogin" ); if (adminuserLogin!=null ){ return true ; } request.getRequestDispatcher("/WEB-INF/jsp/admin/index.jsp" ).forward(request, response); return true ; } @Override public void postHandle (HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3) throws Exception { } @Override
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 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);
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 } } package com.shop.controller;@Controller public class ajaxController { @Autowired private UserService userService; @RequestMapping("/loginFindByid") public void loginFindByid (HttpServletRequest request, HttpServletResponse response, @RequestParam String username) { response.setContentType("text/html;charset=UTF-8" ); try { User user = userService.loginFindByid(username); if (user!=null ) { response.getWriter().write("可以登录" ); }else { response.getWriter().write("不可以登录" ); } } catch (Exception e) { e.printStackTrace(); } } @RequestMapping("/registFindByid") public void registFindByid (HttpServletRequest request, HttpServletResponse response, @RequestParam String username) { response.setContentType("text/html;charset=UTF-8" );
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 int y1; int y2; for (int i = 0 ; i < 30 ; i++) { x1 = random.nextInt(width); x2 = random.nextInt(12 ); y1 = random.nextInt(height); y2 = random.nextInt(12 ); graphics.drawLine(x1, y1, x1 + x2, x2 + y2); } graphics.dispose(); ImageIO.write(bufferedImage, "jpg" , response.getOutputStream()); } private Color getRandColor (int fc, int bc) { Random random = new Random(); if (fc > 255 ) { fc = 255 ; } if (bc > 255 ) { bc = 255 ; } int r = fc + random.nextInt(bc - fc); int g = fc + random.nextInt(bc - fc); int b = fc + random.nextInt(bc - fc); return new Color(r, g, b); } } package com.shop.controller;@Controller public class loginController { @Autowired private UserService userService;
——————————PayStart——————————
项目链接: https://javayms.github.io?id=181023501103200zx https://javayms.pages.dev?id=181023501103200zx