——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明








基于javaweb的SSM+Maven图书商城系统(java+ssm+jsp+javascript+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+css+javascript+jQuery+html
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中db.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 34 35 36 37 38 39 40 41 42
| if(indent!=null){ indent = indentService.lessenIndentItem(indent, tempBook); map.put("status","ok"); } request.getSession().setAttribute("indent",indent); json = mapper.writeValueAsString(map); return json;
}
@RequestMapping("/delete") @ResponseBody public String delete(HttpServletRequest request,@RequestParam(value="bookid", required=true) Integer bookid, HttpServletResponse response) throws ServletException, IOException { Map<String, Object> map = new HashMap<String, Object>(); ObjectMapper mapper = new ObjectMapper(); String json = null; Book tempBook = bookService.findById(bookid); Indent indent = (Indent)request.getSession().getAttribute("indent"); if(indent!=null){ indent = indentService.deleteIndentItem(indent, tempBook); map.put("status","ok"); }
request.getSession().setAttribute("indent",indent); json = mapper.writeValueAsString(map); return json;
}
|
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("/user") public class UserController {
@Autowired private IIndentService indentService;
@Autowired private IUserService userService;
@RequestMapping("/userList") public ModelAndView userList(HttpServletRequest request,@RequestParam(value="page", required=false) Integer page, @RequestParam(value="rows", required=false) Integer rows,Users user, HttpServletResponse response) throws ServletException, IOException { ModelAndView view = new ModelAndView(); if(page==null){ page = 1; }
if(rows==null){ rows = 10; }
List<Users> userList = userService.getPageList(user,page,rows);
PageInfo<Users> pageInfo = new PageInfo<Users>(userList); String pageTool = PageUtil.getPageToolAdmin(request, pageInfo.getTotal(), page, rows); view.addObject("userList",userList); view.addObject("pageTool",pageTool); view.setViewName("jsp/admin/pages/user-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
| ModelAndView view = new ModelAndView();
try { adminService.deleteById(id); } catch (Exception e) { }
view.setViewName("redirect:adminList.do"); return view;
}
} package cn.goodym.util;
public class LoginFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { }
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest servletRequest = (HttpServletRequest) request; HttpServletResponse servletResponse = (HttpServletResponse) response; HttpSession session = servletRequest.getSession(); String path = servletRequest.getRequestURI();
|
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
|
@RequestMapping("/adminAdd") public ModelAndView adminAdd(Admin admin,HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ModelAndView view = new ModelAndView(); admin.setPassword(SafeUtil.encode(admin.getPassword())); adminService.add(admin); view.addObject("msg","新增成功"); view.setViewName("jsp/admin/pages/admin-add"); return view; }
@RequestMapping("/adminRe") public ModelAndView adminRe(Admin admin,HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ModelAndView view = new ModelAndView(); Admin tempAdmin = adminService.findById(admin.getId()); tempAdmin.setPassword(SafeUtil.encode("123456")); adminService.updateById(tempAdmin); view.setViewName("redirect:adminList.do"); return view; }
|
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
| }
List<Category> categoryList = categoryService.getPageList(category,page,rows);
PageInfo<Category> pageInfo = new PageInfo<Category>(categoryList); String pageTool = PageUtil.getPageToolAdmin(request, pageInfo.getTotal(), page, rows); view.addObject("categoryList",categoryList); view.addObject("pageTool",pageTool); view.setViewName("jsp/admin/pages/category-list"); return view; }
@RequestMapping("/toAdd") public ModelAndView toAdd(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ModelAndView view = new ModelAndView(); view.setViewName("jsp/admin/pages/category-add"); return view; }
@RequestMapping("/categoryAdd") public ModelAndView categoryAdd(Category category,HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ModelAndView view = new ModelAndView();
categoryService.add(category); view.addObject("msg","新增成功"); view.setViewName("jsp/admin/pages/category-add"); return view; }
|
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
|
@RequestMapping("/adminList") public ModelAndView adminList(HttpServletRequest request,@RequestParam(value="page", required=false) Integer page, @RequestParam(value="rows", required=false) Integer rows,Admin admin, HttpServletResponse response) throws ServletException, IOException { ModelAndView view = new ModelAndView(); if(page==null){ page = 1; }
if(rows==null){ rows = 10; }
List<Admin> adminList = adminService.getPageList(admin,page,rows);
PageInfo<Admin> pageInfo = new PageInfo<Admin>(adminList); String pageTool = PageUtil.getPageToolAdmin(request, pageInfo.getTotal(), page, rows); view.addObject("adminList",adminList); view.addObject("pageTool",pageTool); view.setViewName("jsp/admin/pages/admin-list"); return view; }
@RequestMapping("/toAdd") public ModelAndView toAdd(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ModelAndView view = new ModelAndView();
view.setViewName("jsp/admin/pages/admin-add"); return view; }
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=161122522008200od
https://javayms.pages.dev?id=161122522008200od