基于javaweb的SSM+Maven酒店管理系统(java+ssm+maven+layui+mysql+jsp)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

040023242402

050023242402

060023242402

070023242402

080023242402

090023242402

基于javaweb的SSM+Maven酒店管理系统(java+ssm+maven+layui+mysql+jsp)

酒店管理系统-温情小筑后台管理系统

系统概要

项目主要功能包括: 住客管理:住客入住、住客列表; 房间管理:房间列表、添加房间、修改房间状态; 会员管理:新增会员、会员列表; 系统设置:网站信息、修改密码、清除缓存; 数据表:生成Excel并导出等功能,适合java新手学习;

技术选型

1.后台技术选型:SSM(Spring SpringMVC Mybatis)

2.前端技术选型:LayUI

开发环境

1.编程语言:Java 2.开发工具:IDEA/Eclipse、Navicat 3.项目构建:Maven 3.5.2 4.服务器:Tomcat 8.0及以上

5.数据库:MySQL5.7

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置; 3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行; 4. 运行项目,输入localhost:8080/ 登录

运行

导入项目并运行成功后,在tomcat路径中设置为/,注意路径中不要带有项目名,否则会导致项目运行异常;

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

@Controller
@RequestMapping("/home")

public class HomeController {

@Autowired
HomeServiceImpl homeService;

@RequestMapping("/add")
public String add(Home home, Model model) throws IOException{

String sqlPath = null;
//定义文件保存的本地路径
// String localPath="/DownLoad/";
String localPath="/Users/admin/Desktop/log/";
//定义 文件名
String filename=null;
if(!home.getFile().isEmpty()){
//生成uuid作为文件名称
String uuid = UUID.randomUUID().toString().replaceAll("-","");
//获得文件类型(可以判断如果不是图片,禁止上传)
String contentType=home.getFile().getContentType();
//获得文件后缀名
String suffixName=contentType.substring(contentType.indexOf("/")+1);
//得到 文件名
filename=uuid+"."+suffixName;
System.out.println(filename);
//文件保存路径
home.getFile().transferTo(new File(localPath+filename));
}
//把图片的相对路径保存至数据库
sqlPath = "/upload/"+filename;
System.out.println(sqlPath);
home.setImg(sqlPath);

homeService.addHome(home);
model.addAttribute("home",home);
return "home_show";
}

@RequestMapping("/delete")
public String delete(Integer id){
homeService.deleteHomeById(id);
return "redirect:/home/list";
}

@RequestMapping("/list")
public ModelAndView list(){
ModelAndView mv = new ModelAndView();
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
        //定义文件保存的本地路径
// String localPath="/Download/";
String localPath="/Users/admin/Desktop/log/";
//定义 文件名
String filename=null;
if(!h.getFile().isEmpty()){
//生成uuid作为文件名称
String uuid = UUID.randomUUID().toString().replaceAll("-","");
//获得文件类型(可以判断如果不是图片,禁止上传)
String contentType=h.getFile().getContentType();
//获得文件后缀名
String suffixName=contentType.substring(contentType.indexOf("/")+1);
//得到 文件名
filename=uuid+"."+suffixName;
System.out.println(filename);
//文件保存路径
h.getFile().transferTo(new File(localPath+filename));
}
//把图片的相对路径保存至数据库
sqlPath = "/upload/"+filename;
System.out.println(sqlPath);
h.setImg(sqlPath);

homeService.updateHomeById(h);
return ("redirect:/home/list");
}

@RequestMapping("/show")
public ModelAndView show(Integer id){
ModelAndView mv = new ModelAndView();
Home home=homeService.queryHomeById(id);
mv.addObject("home",home);
mv.setViewName("home_show");
return mv;
}

@RequestMapping("/find")
public ModelAndView find(int findByNum ){
ModelAndView mv = new ModelAndView();
Home home = homeService.queryHomeByNum(findByNum);
List<Home> homeList=new ArrayList<Home>();
homeList.add(home);
if (home==null){
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
    }
}

package com.hotel.controller;


@Controller
@RequestMapping("jump")
public class JumpController {

@RequestMapping("/guests_add")
public String guest(){
return "guests_add";
}

@RequestMapping("/vip_add")
public String vip(){
return "vip_add";
}

@RequestMapping("/home_add")
public String home(){
return "home_add";
}

@RequestMapping("/pwd_update")
public String pwd(){
return "pwd_update";
}

@RequestMapping("/excel_down")
public String excel(){
return "excel_down";
}

@RequestMapping("/web_cache")
public String cache(){
return "web_cache";
}

@RequestMapping("/web_index")
public String web_index(){
return "web_index";
}

@RequestMapping("/index")
public String index(){
return "index";
}

@RequestMapping("/exit")
public String exit(){
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

//获取需要下载表对应的pojo类
for(Home home:homeList){
HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum()+1);
dataRow.createCell(0).setCellValue(home.getId());
dataRow.createCell(1).setCellValue(home.getNum());
dataRow.createCell(2).setCellValue(home.getH_Type());
dataRow.createCell(3).setCellValue(home.getPrice());
dataRow.createCell(4).setCellValue(home.getState());
dataRow.createCell(5).setCellValue(home.getText());
}

// 设置下载时客户端Excel的名称
response.setContentType("application/octet-stream;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename="
+ new String("房间信息表".getBytes(),"iso-8859-1") + ".xls");

OutputStream ouputStream = response.getOutputStream();
wb.write(ouputStream);
ouputStream.flush();
ouputStream.close();

}

@RequestMapping("/vip")
public void excel_vip(HttpServletResponse response )throws IOException {

response.setCharacterEncoding("UTF-8");
List<Vip> vipList=vipService.queryAllVip();
//创建excel文件
HSSFWorkbook wb = new HSSFWorkbook();
//创建sheet页
HSSFSheet sheet = wb.createSheet("会员信息");
//创建标题行
HSSFRow titleRow = sheet.createRow(0);
titleRow.createCell(0).setCellValue("编号");
titleRow.createCell(1).setCellValue("姓名");
titleRow.createCell(2).setCellValue("性别");
titleRow.createCell(3).setCellValue("身份证号");
titleRow.createCell(4).setCellValue("手机号");
titleRow.createCell(5).setCellValue("会员类型");
titleRow.createCell(6).setCellValue("开通时间");
titleRow.createCell(7).setCellValue("到期时间");

for(Vip vip:vipList){
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 ModelAndView find(String findByPhone ){
ModelAndView mv = new ModelAndView();
Vip vip = vipService.queryVipByPhone(findByPhone);
List<Vip> vipList=new ArrayList<Vip>();
vipList.add(vip);
if (vip==null){
vipList=vipService.queryAllVip();
mv.addObject("error","未查询出结果");
}
mv.addObject("list",vipList);
mv.setViewName("vip_list");
return mv;
}
}

package com.hotel.controller;


@Controller
@RequestMapping("jump")
public class JumpController {

@RequestMapping("/guests_add")
public String guest(){
return "guests_add";
}

@RequestMapping("/vip_add")
public String vip(){
return "vip_add";
}

@RequestMapping("/home_add")
public String home(){
return "home_add";
}

@RequestMapping("/pwd_update")
public String pwd(){
return "pwd_update";
}

@RequestMapping("/excel_down")
public String excel(){
return "excel_down";
}


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