基于javaweb的SSM+Maven校园鲜花销售商城系统(java+ssm+jsp+layui+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

132323261507

030023142402

040023142402

050023142402

070023142402

080023142402

090023142402

基于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等等。

功能介绍:用户管理、商品管理、评论管理、订单管理、管理员管理、资讯管理、登录注册 等等。

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://yms-1257401191.cos.ap-nanjing.myqcloud.com/product"),imageName);

System.out.println(session.getServletContext().getRealPathhttps://yms-1257401191.cos.ap-nanjing.myqcloud.com/product"));

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://yms-1257401191.cos.ap-nanjing.myqcloud.com/product"),imageName);
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

/**
* 前台登陆状态拦截器 如果访问的请求没有在noNeedAuthPage数组就跳转登陆
*/
public class LoginInterceptor extends HandlerInterceptorAdapter {
@Autowired
OrderItemService orderItemService;
/**
* 在业务处理器处理请求之前被调用
* 如果返回false
* 从当前的拦截器往回执行所有拦截器的afterCompletion(),再退出拦截器链
* 如果返回true
* 执行下一个拦截器,直到所有的拦截器都执行完毕
* 再执行被拦截的Controller
* 然后进入拦截器链,
* 从最后一个拦截器往回执行所有的postHandle()
* 接着再从最后一个拦截器往回执行所有的afterCompletion()
*/
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
/**
* 不需要登录也可以访问的
* 注册,登录,产品,首页,分类,查询等等
* 需要登录才能够访问的
* 购买行为,加入购物车行为,查看购物车,查看我的订单等等
* 不需要登录也可以访问的已经确定了,但是需要登录才能够访问,截止目前为止还不能确定,所以这个过滤器就判断如果不是注册,登录,产品这些,就进行登录校验
* 1. 准备字符串数组 noNeedAuthPage,存放哪些不需要登录也能访问的路径
* 2. 获取uri
* 3. 去掉前缀/fore
* 4. 如果访问的地址是/fore开头
* 4.1 取出fore后面的字符串,比如是forecart,那么就取出cart
* 4.2 判断cart是否是在noNeedAuthPage
* 4.2 如果不在,那么就需要进行是否登录验证
* 4.3 从session中取出"cst"对象
* 4.4 如果对象不存在,就客户端跳转到login.jsp
* 4.5 否则就正常执行
*/
HttpSession session = request.getSession();
String contextPath=session.getServletContext().getContextPath()+"/fore";
//准备字符串数组 noNeedAuthPage,存放哪些不需要登录也能访问的路径
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
*/
@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://yms-1257401191.cos.ap-nanjing.myqcloud.com/product"),imageName);

System.out.println(session.getServletContext().getRealPathhttps://yms-1257401191.cos.ap-nanjing.myqcloud.com/product"));

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://yms-1257401191.cos.ap-nanjing.myqcloud.com/product"),imageName);
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
*/
@Controller
@RequestMapping("/config")
public class PermissionController {
@Autowired
PermissionService permissionService;

/**
* 添加权限页面
* @return
*/
@RequestMapping("/adminPerAddUI")
public String addUI(){
return "syspage/admin-permission-add";
}

/**
* 权限列表
* @param model
* @param page
* @return
*/
@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);


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