——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
后台管理:用户、新闻公告、果蔬类型、城市信息、配货点、果蔬商品、订单、评价等管理等
前台购物:注册登录、公告、商品、购买、评价等
idea:

eclipse/myeclipse:

前台购物:














后台管理:








技术框架
JavaBean MVC JSP SSM(Spring SpringMVC MyBatis) MySQL Bootstrap JavaScript
基于javaweb的SSM在线商城购物商城水果蔬菜批发商城(前台、后台)(java+javabean+mysql+jsp+ssm)
——————————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
| public static void getPage(List<?> list, String name, List<String> nameList, List<String> valueList, int pageSize, String number, HttpServletRequest request, String method) { StringBuffer buffer = new StringBuffer(); String name2 = name.substring(0, 1).toUpperCase() + name.substring(1); String path = ""; String action = "getAll" + name2 + ".action"; if (method != null) { action = "query" + name2 + "ByCond.action"; }
List<Object> objList = new ArrayList<Object>(); if (nameList != null && valueList != null) { for (int i = 0; i < nameList.size(); i++) { path += "&" + nameList.get(i) + "=" + valueList.get(i); } } int pageNumber = list.size(); int maxPage = pageNumber; if (maxPage % 10 == 0) { maxPage = maxPage / 10; } else { maxPage = maxPage / 10 + 1; } if (number == null) { number = "0"; } int start = Integer.parseInt(number) * 10; int over = (Integer.parseInt(number) + 1) * 10; int count = pageNumber - over; if (count <= 0) { over = pageNumber; } for (int i = start; i < over; i++) { Object obj = list.get(i); objList.add(obj); } buffer.append(" 共为"); buffer.append(maxPage); buffer.append("页 共有"); buffer.append(pageNumber); buffer.append("条 当前为第"); buffer.append((Integer.parseInt(number) + 1)); buffer.append("页 "); if ((Integer.parseInt(number) + 1) == 1) { buffer.append("首页");
|
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
| @RequestMapping(value = "/image.action") public String upload(@RequestParam(value = "image", required = false) MultipartFile file, HttpServletRequest request, ModelMap model) { String path = request.getSession().getServletContext().getRealPath("/") + "upfiles/"; String fileName = file.getOriginalFilename(); int i = fileName.lastIndexOf("."); String name = String.valueOf(VeDate.getStringDatex()); String type = fileName.substring(i + 1); fileName = name + "." + type; File targetFile = new File(path, fileName); if (!targetFile.exists()) { targetFile.mkdirs(); }
try { file.transferTo(targetFile); } catch (Exception e) { e.printStackTrace(); } model.addAttribute("imageFileName", fileName); return "saveimage"; }
@RequestMapping(value = "/files.action") public String files(@RequestParam(value = "image", required = false) MultipartFile file, HttpServletRequest request, ModelMap model) { String path = request.getSession().getServletContext().getRealPath("/") + "upfiles/"; String fileName = file.getOriginalFilename(); int i = fileName.lastIndexOf("."); String name = String.valueOf(VeDate.getStringDatex()); String type = fileName.substring(i + 1); fileName = name + "." + type; File targetFile = new File(path, fileName); if (!targetFile.exists()) { targetFile.mkdirs(); }
try { file.transferTo(targetFile); } catch (Exception e) { e.printStackTrace(); }
|
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
| articleList.add(x); } String html = ""; StringBuffer buffer = new StringBuffer(); buffer.append(" 共为"); buffer.append(maxPage); buffer.append("页 共有"); buffer.append(pageNumber); buffer.append("条 当前为第"); buffer.append((Integer.parseInt(number) + 1)); buffer.append("页 "); if ((Integer.parseInt(number) + 1) == 1) { buffer.append("首页"); } else { buffer.append("<a href=\"index/article.action?number=0\">首页</a>"); } buffer.append(" "); if ((Integer.parseInt(number) + 1) == 1) { buffer.append("上一页"); } else { buffer.append("<a href=\"index/article.action?number=" + (Integer.parseInt(number) - 1) + "\">上一页</a>"); } buffer.append(" "); if (maxPage <= (Integer.parseInt(number) + 1)) { buffer.append("下一页"); } else { buffer.append("<a href=\"index/article.action?number=" + (Integer.parseInt(number) + 1) + "\">下一页</a>"); } buffer.append(" "); if (maxPage <= (Integer.parseInt(number) + 1)) { buffer.append("尾页"); } else { buffer.append("<a href=\"index/article.action?number=" + (maxPage - 1) + "\">尾页</a>"); } html = buffer.toString(); this.getRequest().setAttribute("html", html); this.getRequest().setAttribute("articleList", articleList); return "users/article"; }
// 阅读公告 @RequestMapping("read.action") public String read(String id) { this.front();
|
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
| public String updateArticle(Article article) { this.articleService.updateArticle(article); return "redirect:/article/getAllArticle.action"; }
@RequestMapping("getAllArticle.action") public String getAllArticle(String number) { List<Article> articleList = this.articleService.getAllArticle(); PageHelper.getPage(articleList, "article", null, null, 10, number, this.getRequest(), null); return "admin/listarticle"; }
@RequestMapping("queryArticleByCond.action") public String queryArticleByCond(String cond, String name, String number) { Article article = new Article(); if (cond != null) { if ("title".equals(cond)) { article.setTitle(name); } if ("image".equals(cond)) { article.setImage(name); } if ("contents".equals(cond)) { article.setContents(name); } if ("addtime".equals(cond)) { article.setAddtime(name); } if ("hits".equals(cond)) { article.setHits(name); } }
List<String> nameList = new ArrayList<String>(); List<String> valueList = new ArrayList<String>(); nameList.add(cond); valueList.add(name); PageHelper.getPage(this.articleService.getArticleByLike(article), "article", nameList, valueList, 10, number, this.getRequest(), "query"); name = null; cond = null; return "admin/queryarticle"; }
|
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
| public OrdersService getOrdersService() { return ordersService; }
public void setOrdersService(OrdersService ordersService) { this.ordersService = ordersService; }
} package com.action;
@Controller
@RequestMapping(value = "/article", produces = "text/plain;charset=utf-8") public class ArticleAction extends BaseAction { @Autowired @Resource private ArticleService articleService;
@RequestMapping("createArticle.action") public String createArticle() { return "admin/addarticle"; }
@RequestMapping("addArticle.action") public String addArticle(Article article) { article.setAddtime(VeDate.getStringDateShort()); article.setHits("0"); this.articleService.insertArticle(article); return "redirect:/article/createArticle.action"; }
@RequestMapping("deleteArticle.action") public String deleteArticle(String id) { this.articleService.deleteArticle(id);
|
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
|
@Controller
@RequestMapping(value = "/cart", produces = "text/plain;charset=utf-8") public class CartAction extends BaseAction { @Autowired @Resource private CartService cartService; @Autowired @Resource private UsersService usersService; @Autowired @Resource private JiancaiService jiancaiService;
@RequestMapping("createCart.action") public String createCart() { List<Users> usersList = this.usersService.getAllUsers(); this.getRequest().setAttribute("usersList", usersList); List<Jiancai> jiancaiList = this.jiancaiService.getAllJiancai(); this.getRequest().setAttribute("jiancaiList", jiancaiList); return "admin/addcart"; }
@RequestMapping("addCart.action") public String addCart(Cart cart) { this.cartService.insertCart(cart); return "redirect:/cart/createCart.action"; }
@RequestMapping("deleteCart.action") public String deleteCart(String id) {
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=271622552602103ad
https://javayms.pages.dev?id=271622552602103ad