基于javaweb的SSM电商平台网上超市在线购物商城系统(java+ssm+javascript+jsp+mysql+tomcat)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

122124520601

142124520601

152124520601

162124520601

172124520601

182124520601

192124520601

202124520601

基于javaweb的SSM电商平台网上超市在线购物商城系统(java+ssm+javascript+jsp+mysql+tomcat)

1
2
3
4
5
6
7
8
前台用户:
user1@qq.com 123456
user2@qq.com 123456



后台管理员:
admin 123456

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

BufferedImage image = new BufferedImage(WIDTH, HEIGHT,
BufferedImage.TYPE_INT_RGB);
Font mFont = new Font("Arial", Font.TRUETYPE_FONT, 18);
Graphics g = image.getGraphics();
Random rd = new Random();

// 设置背景颜色
g.setColor(new Color(rd.nextInt(55) + 200, rd.nextInt(55) + 200, rd
.nextInt(55) + 200));
g.fillRect(0, 0, WIDTH, HEIGHT);

// 设置字体
g.setFont(mFont);

// 画边框
g.setColor(Color.black);
g.drawRect(0, 0, WIDTH - 1, HEIGHT - 1);

// 随机产生的验证码
String result = "";
for (int i = 0; i < LENGTH; ++i) {
result += code[rd.nextInt(code.length)];
}
HttpSession se = request.getSession();
se.setAttribute("code", result);

// 画验证码
for (int i = 0; i < result.length(); i++) {
g.setColor(new Color(rd.nextInt(200), rd.nextInt(200), rd
.nextInt(200)));
g.drawString(result.charAt(i) + "", 12 * i + 1, 16);
}

// 随机产生2个干扰线
for (int i = 0; i < 2; i++) {
g.setColor(new Color(rd.nextInt(200), rd.nextInt(200), rd
.nextInt(200)));
int x1 = rd.nextInt(WIDTH);
int x2 = rd.nextInt(WIDTH);
int y1 = rd.nextInt(HEIGHT);
int y2 = rd.nextInt(HEIGHT);
g.drawLine(x1, y1, x2, y2);
}

// 释放图形资源
g.dispose();
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
	public String selectCart(Model model, HttpSession session) {
List<Map<String, Object>> list = cartDao.selectCart(MyUtil.getUserId(session));
double sum = 0;
for (Map<String, Object> map : list) {
sum = sum + (Double)map.get("smallsum");
}
model.addAttribute("total", sum);
model.addAttribute("cartlist", list);
return "before/cart";
}
@Override
public String deleteAgoods(Integer id, HttpSession session) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("uid", MyUtil.getUserId(session));
map.put("gid", id);
cartDao.deleteAgoods(map);
return "forward:/cart/selectCart";
}
@Override
public String clear(HttpSession session) {
cartDao.clear(MyUtil.getUserId(session));
return "forward:/cart/selectCart";
}
@Override
public String orderConfirm(Model model, HttpSession session) {
List<Map<String, Object>> list = cartDao.selectCart(MyUtil.getUserId(session));
double sum = 0;
for (Map<String, Object> map : list) {
sum = sum + (Double)map.get("smallsum");
}
model.addAttribute("total", sum);
model.addAttribute("cartlist", list);
return "before/orderconfirm";
}

}




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



@Service("userService")
@Transactional
public class UserServiceImpl implements UserService{
@Autowired
private UserDao userDao;
@Override
public String register(Buser buser, Model model, HttpSession session, String code) {
if(!code.equalsIgnoreCase(session.getAttribute("code").toString())) {
model.addAttribute("codeError", "验证码错误!");
return "before/register";
}
int n = userDao.register(buser);
if(n > 0) {
return "before/login";
}else {
model.addAttribute("msg", "注册失败!");
return "before/register";
}
}
@Override
public String login(Buser buser, Model model, HttpSession session, String code) {
if(!code.equalsIgnoreCase(session.getAttribute("code").toString())) {
model.addAttribute("msg", "验证码错误!");
return "before/login";
}
Buser ruser = null;
List<Buser> list = userDao.login(buser);
if(list.size() > 0) {
ruser = list.get(0);
}
if(ruser != null) {
session.setAttribute("bruser", ruser);
return "forward:/before";
}else {
model.addAttribute("msg", "用户名或密码错误!");
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
	/**
* 删除单个商品
*/
@RequestMapping("/deleteAGoods")
public String deleteAGoods(Integer id, Model model) {
return adminGoodsService.deleteAGoods(id, model);
}
}




@Controller
@RequestMapping("/cart")
public class CartController extends BaseBeforeController{
@Autowired
private CartService cartService;
/**
* 关注商品
*/
@RequestMapping("/focus")
public String focus(Model model,Integer id, HttpSession session) {
return cartService.focus(model, id, session);
}
/**
* 添加购物车
*/
@RequestMapping("/putCart")
public String putCart(Model model,Integer shoppingnum, Integer id, HttpSession session) {
return cartService.putCart(model, shoppingnum, id, session);
}
/**
* 查询购物车
*/
@RequestMapping("/selectCart")
public String selectCart(Model model, HttpSession session) {
return cartService.selectCart(model, session);
}
/**
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
        	arg0.setAttribute("auser", new Auser());
arg0.setAttribute("msg", "没有登录,请登录!");
return new ModelAndView("/admin/login", model);
} else if(arg3 instanceof UserLoginNoException){
arg0.setAttribute("buser", new Buser());
arg0.setAttribute("msg", "没有登录,请登录!");
return new ModelAndView("/before/login", model);
}else{
return new ModelAndView("/error/error", model);
}
}
}
@Controller
@RequestMapping("/adminNotice")
public class AdminNoticeController extends BaseController{
@Autowired
private AdminNoticeService adminNoticeService;
@RequestMapping("/toAddNotice")
public String toAddNotice(Model model) {
model.addAttribute("notice", new Notice());
return "admin/addNotice";
}
@RequestMapping("/addNotice")
public String addNotice(@ModelAttribute Notice notice) {
return adminNoticeService.addNotice(notice);
}
@RequestMapping("/deleteNoticeSelect")
public String deleteNoticeSelect(Model model) {
return adminNoticeService.deleteNoticeSelect(model);
}
@RequestMapping("/selectANotice")
public String selectANotice(Model model, Integer id) {
return adminNoticeService.selectANotice(model, 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
39
40
41
42
43
44
45
46
		}
}
@Override
public String login(Buser buser, Model model, HttpSession session, String code) {
if(!code.equalsIgnoreCase(session.getAttribute("code").toString())) {
model.addAttribute("msg", "验证码错误!");
return "before/login";
}
Buser ruser = null;
List<Buser> list = userDao.login(buser);
if(list.size() > 0) {
ruser = list.get(0);
}
if(ruser != null) {
session.setAttribute("bruser", ruser);
return "forward:/before";
}else {
model.addAttribute("msg", "用户名或密码错误!");
return "before/login";
}
}

}



@Service("adminTypeService")
@Transactional
public class AdminTypeServiceImpl implements AdminTypeService{
@Autowired
private AdminTypeDao adminTypeDao;

@Override
public String toAddType(Model model) {
model.addAttribute("allTypes", adminTypeDao.selectGoodsType());
return "admin/addType";
}

@Override
public String addType(String typename, Model model, HttpSession session) {
adminTypeDao.addType(typename);
//添加商品与修改商品页面使用
session.setAttribute("goodsType", adminTypeDao.selectGoodsType());
return "forward:/adminType/toAddType";
}


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