基于javaweb的SSM在线商城购物商城水果蔬菜批发商城(前台、后台)(java+javabean+mysql+jsp+ssm)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

后台管理:用户、新闻公告、果蔬类型、城市信息、配货点、果蔬商品、订单、评价等管理等

前台购物:注册登录、公告、商品、购买、评价等

idea:

430123152502

eclipse/myeclipse:

440123152502

前台购物:

270123152502

280123152502

290123152502

300123152502

320123152502

330123152502

340123152502

350123152502

360123152502

370123152502

380123152502

390123152502

400123152502

410123152502

后台管理:

180123152502

190123152502

210123152502

220123152502

230123152502

240123152502

250123152502

260123152502

技术框架

JavaBean MVC JSP SSM(Spring SpringMVC MyBatis) MySQL Bootstrap JavaScript

基于javaweb的SSM在线商城购物商城水果蔬菜批发商城(前台、后台)(java+javabean+mysql+jsp+ssm)

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("&nbsp;&nbsp;共为");
buffer.append(maxPage);
buffer.append("页&nbsp; 共有");
buffer.append(pageNumber);
buffer.append("条&nbsp; 当前为第");
buffer.append((Integer.parseInt(number) + 1));
buffer.append("页 &nbsp;");
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("&nbsp;&nbsp;共为");
buffer.append(maxPage);
buffer.append("页&nbsp; 共有");
buffer.append(pageNumber);
buffer.append("条&nbsp; 当前为第");
buffer.append((Integer.parseInt(number) + 1));
buffer.append("页 &nbsp;");
if ((Integer.parseInt(number) + 1) == 1) {
buffer.append("首页");
} else {
buffer.append("<a href=\"index/article.action?number=0\">首页</a>");
}
buffer.append("&nbsp;&nbsp;");
if ((Integer.parseInt(number) + 1) == 1) {
buffer.append("上一页");
} else {
buffer.append("<a href=\"index/article.action?number=" + (Integer.parseInt(number) - 1) + "\">上一页</a>");
}
buffer.append("&nbsp;&nbsp;");
if (maxPage <= (Integer.parseInt(number) + 1)) {
buffer.append("下一页");
} else {
buffer.append("<a href=\"index/article.action?number=" + (Integer.parseInt(number) + 1) + "\">下一页</a>");
}
buffer.append("&nbsp;&nbsp;");
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 {
// 注入Service 由于标签的存在 所以不需要getter setter
@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 {
// 注入Service 由于标签的存在 所以不需要getter setter
@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) {


项目链接:
https://javayms.github.io?id=271622552602103ad
https://javayms.pages.dev?id=271622552602103ad