——————————DescriptionStart——————————
运行环境 Java≥8、MySQL≥5.7、Tomcat≥8
开发工具 eclipse/idea/myeclipse/sts等均可配置运行
适用 课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM+Maven校园鲜花销售商城系统(java+ssm+jsp+layui+mysql)
一、项目简述 环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等。
功能介绍:用户管理、商品管理、评论管理、订单管理、管理员管理、资讯管理、登录注册 等等。
——————————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 47 public String addUI (Model model) { List<Category> categoryList = categoryService.list(); List<User> userList = userService.list(); model.addAttribute("categoryList" ,categoryList); model.addAttribute("userList" ,userList); return "productmodule/product-add" ; } @RequestMapping("/addProduct") public String add (Product product, HttpSession session, UploadUtil upload) throws IOException { productService.save(product); if (upload != null ) { String imageName = product.getId()+".jpg" ; File file = new File(session.getServletContext().getRealPathhttps: System.out.println(session.getServletContext().getRealPathhttps: file.getParentFile().mkdirs(); upload.getImage().transferTo(file); System.out.println("[" +product.getId()+"," +"images/product/" +imageName+"]" ); ProductVO vo = new ProductVO(); vo.setId(product.getId()); vo.setImageUrl("images/product/" +imageName); productService.setImageURL(vo); System.out.println(productService.get(product.getId())); } return "redirect:list" ; } @RequestMapping("/deleteProduct") public String del (@RequestParam(value = "id") int id, HttpSession session) { productService.del(id); String imageName = id+".jpg" ; File file = new File(session.getServletContext().getRealPathhttps: file.delete(); return "redirect:list" ;
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 public class LoginInterceptor extends HandlerInterceptorAdapter { @Autowired OrderItemService orderItemService; @Override public boolean preHandle (HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { HttpSession session = request.getSession(); String contextPath=session.getServletContext().getContextPath()+"/fore" ; String[] noNeedAuthPage = new String[]{ "Index" ,
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 @Controller @RequestMapping("/config") public class UserController { @Autowired UserRoleService userRoleService; @Autowired UserService userService; @Autowired RoleService roleService; @RequestMapping("/enableStatus") @ResponseBody public String enableStatus (@RequestParam(value = "name") String name) { return userService.enableStatus(name); } @RequestMapping("/stopStatus") @ResponseBody public String stopStatus (@RequestParam(value = "name") String name) { return userService.stopStatus(name); } @RequestMapping("/adminAdd") public String adminadd (Model model) { List<Role> list = roleService.list(); model.addAttribute("rolelist" ,list); return "syspage/admin-add" ; } @RequestMapping("/listUser") public String list (Model model, Page page) { PageHelper.offsetPage(page.getStart(),page.getCount()); List<User> us= userService.list(); int total = (int ) new PageInfo<>(us).getTotal(); page.setTotal(total); model.addAttribute("us" , us); model.addAttribute("total" ,total); Map<User,List<Role>> user_roles = new HashMap<>(); for (User user : us) {
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 return productService.stopStatus(name); } @RequestMapping("/productAddUI") public String addUI (Model model) { List<Category> categoryList = categoryService.list(); List<User> userList = userService.list(); model.addAttribute("categoryList" ,categoryList); model.addAttribute("userList" ,userList); return "productmodule/product-add" ; } @RequestMapping("/addProduct") public String add (Product product, HttpSession session, UploadUtil upload) throws IOException { productService.save(product); if (upload != null ) { String imageName = product.getId()+".jpg" ; File file = new File(session.getServletContext().getRealPathhttps: System.out.println(session.getServletContext().getRealPathhttps: file.getParentFile().mkdirs(); upload.getImage().transferTo(file); System.out.println("[" +product.getId()+"," +"images/product/" +imageName+"]" ); ProductVO vo = new ProductVO(); vo.setId(product.getId()); vo.setImageUrl("images/product/" +imageName); productService.setImageURL(vo); System.out.println(productService.get(product.getId())); } return "redirect:list" ; } @RequestMapping("/deleteProduct") public String del (@RequestParam(value = "id") int id, HttpSession session) { productService.del(id); String imageName = id+".jpg" ; File file = new File(session.getServletContext().getRealPathhttps:
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 @Controller @RequestMapping("/config") public class PermissionController { @Autowired PermissionService permissionService; @RequestMapping("/adminPerAddUI") public String addUI () { return "syspage/admin-permission-add" ; } @RequestMapping("/listPermission") public String list (Model model, Page page) { PageHelper.offsetPage(page.getStart(),page.getCount()); List<Permission> ps= permissionService.list(); int total = (int ) new PageInfo<>(ps).getTotal(); page.setTotal(total); model.addAttribute("ps" , ps); model.addAttribute("perCount" ,ps.size()); return "syspage/admin-permission" ; } @RequestMapping("/editPermission") public String list (Model model, long id) { Permission permission =permissionService.get(id); model.addAttribute("permission" , permission); return "syspage/admin-permission-edit" ; }
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 @RequestMapping("/listRole") public String list (Model model, Page page) { PageHelper.offsetPage(page.getStart(),page.getCount()); List<Role> rs= roleService.list(); int total = (int ) new PageInfo<>(rs).getTotal(); page.setTotal(total); model.addAttribute("rs" , rs); model.addAttribute("roleSize" ,total); Map<Role,List<Permission>> role_permissions = new HashMap<>(); for (Role role : rs) { List<Permission> ps = permissionService.list(role); role_permissions.put(role, ps); } model.addAttribute("role_permissions" , role_permissions); return "syspage/admin-role" ; } @RequestMapping("/editRole") public String list (Model model, long id) { Role role =roleService.get(id); model.addAttribute("role" , role); List<Permission> ps = permissionService.list(); model.addAttribute("ps" , ps); List<Permission> currentPermissions = permissionService.list(role); model.addAttribute("currentPermissions" , currentPermissions); return "syspage/admin-role-edit" ; } @RequestMapping("/updateRole") public String update (Role role,long [] permissionIds) { rolePermissionService.setPermissions(role, permissionIds); roleService.update(role); return "redirect:listRole" ; } @RequestMapping("/addRole") public String list (Model model, Role role) { roleService.add(role);
——————————PayStart——————————
项目链接: https://javayms.github.io?id=081422292105200ej https://javayms.pages.dev?id=081422292105200ej