基于javaweb+mysql的ssm+maven精品酒店管理系统(java+ssm+mysql+maven+jsp)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM+Maven精品酒店管理系统(java+ssm+mysql+maven+jsp)
一、项目简述
功能:主要功能主要功能会员管理,住客管理,房间管 理,系统管理,以及一些重要数据的展示导出维护等等;
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等。
public ModelAndView list(){
ModelAndView mv = new ModelAndView();
List<Guests> guestsList=guestsService.queryAllGuests();
mv.addObject("list",guestsList);
mv.setViewName("guests_list");
return mv;
}
@RequestMapping("/update1")
public ModelAndView update1(int id){
ModelAndView mv = new ModelAndView();
Guests guests = guestsService.queryGuestsById(id);
mv.addObject("g",guests);
mv.setViewName("guests_update");
return mv;
}
@RequestMapping("/update2")
public String update2(Guests g ){
guestsService.updateGuestsById(g);
return ("redirect:/guests/list");
}
@RequestMapping("/find")
public ModelAndView find(String findByPhone){
ModelAndView mv = new ModelAndView();
Guests guests = guestsService.queryGuestsByPhone(findByPhone);
List<Guests> guestsList=new ArrayList<Guests>();
guestsList.add(guests);
if (guests==null){
guestsList=guestsService.queryAllGuests();
mv.addObject("error","未查询出结果");
}
mv.addObject("list",guestsList);
mv.setViewName("guests_list");
return mv;
}
}
@Controller
@RequestMapping("/vip")
public class VipController {
homeList.add(home);
if (home==null){
homeList=homeService.queryAllHome();
mv.addObject("error","未查询出结果");
}
mv.addObject("list",homeList);
mv.setViewName("home_list");
return mv;
}
@RequestMapping("/type1")
public String type1(Integer id,Model model){
Home home = homeService.queryHomeById(id);
model.addAttribute("h",home);
return "H_Type_update";
}
@RequestMapping("/type2")
public String type2(Home home){
homeService.updateH_TypeById(home);
return "redirect:/home/list";
}
}
@Controller
@RequestMapping("/excel")
public class ExcelController {
@Autowired
HomeServiceImpl homeService;
@Autowired
VipServiceImpl vipService;
@RequestMapping("/home")
public void excel_home(HttpServletResponse response )throws IOException {
response.setCharacterEncoding("UTF-8");
@Controller
@RequestMapping("/guests")
public class GuestsController {
@Autowired
GuestsServiceImpl guestsService;
@RequestMapping("/add")
public ModelAndView add(Guests guests){
ModelAndView mv = new ModelAndView();
guestsService.addGuests(guests);
mv.setViewName("suc_g");
return mv;
}
@RequestMapping("/delete")
public String delete(int id){
guestsService.deleteGuestsById(id);
return "redirect:/guests/list";
}
@RequestMapping("/list")
public ModelAndView list(){
ModelAndView mv = new ModelAndView();
List<Guests> guestsList=guestsService.queryAllGuests();
mv.addObject("list",guestsList);
mv.setViewName("guests_list");
return mv;
}
@RequestMapping("/update1")
public ModelAndView update1(int id){
ModelAndView mv = new ModelAndView();
Guests guests = guestsService.queryGuestsById(id);
mv.addObject("g",guests);
mv.setViewName("guests_update");
return mv;
}
@RequestMapping("/update2")
public String update2(Guests g ){
guestsService.updateGuestsById(g);
return ("redirect:/guests/list");
mv.setViewName("guests_list");
return mv;
}
@RequestMapping("/update1")
public ModelAndView update1(int id){
ModelAndView mv = new ModelAndView();
Guests guests = guestsService.queryGuestsById(id);
mv.addObject("g",guests);
mv.setViewName("guests_update");
return mv;
}
@RequestMapping("/update2")
public String update2(Guests g ){
guestsService.updateGuestsById(g);
return ("redirect:/guests/list");
}
@RequestMapping("/find")
public ModelAndView find(String findByPhone){
ModelAndView mv = new ModelAndView();
Guests guests = guestsService.queryGuestsByPhone(findByPhone);
List<Guests> guestsList=new ArrayList<Guests>();
guestsList.add(guests);
if (guests==null){
guestsList=guestsService.queryAllGuests();
mv.addObject("error","未查询出结果");
}
mv.addObject("list",guestsList);
mv.setViewName("guests_list");
return mv;
}
}
@Controller
@RequestMapping("/excel")
public class ExcelController {
@Autowired
HomeServiceImpl homeService;
@Autowired
VipServiceImpl vipService;
@RequestMapping("/home")
public void excel_home(HttpServletResponse response )throws IOException {
response.setCharacterEncoding("UTF-8");
List<Home> homeList=homeService.queryAllHome();
//创建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("描述");
//获取需要下载表对应的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());
Vip vip = vipService.queryVipById(id);
mv.addObject("v",vip);
mv.setViewName("vip_update");
return mv;
}
@RequestMapping("/update2")
public String update2(Vip v){
vipService.updateVipById(v);
return ("redirect:/vip/list");
}
@RequestMapping("/find")
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;
}
}
@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")
@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("/type1")
public String type1(Integer id,Model model){
Home home = homeService.queryHomeById(id);
model.addAttribute("h",home);
return "H_Type_update";
}
@RequestMapping("/type2")
public String type2(Home home){
homeService.updateH_TypeById(home);
return "redirect:/home/list";
}
}
@Controller
@RequestMapping("/excel")
public class ExcelController {
@Autowired
HomeServiceImpl homeService;
@Autowired
VipServiceImpl vipService;
@RequestMapping("/home")
titleRow.createCell(6).setCellValue("开通时间");
titleRow.createCell(7).setCellValue("到期时间");
for(Vip vip:vipList){
HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum()+1);
dataRow.createCell(0).setCellValue(vip.getId());
dataRow.createCell(1).setCellValue(vip.getName());
dataRow.createCell(2).setCellValue(vip.getSex());
dataRow.createCell(3).setCellValue(vip.getCard());
dataRow.createCell(4).setCellValue(vip.getPhone());
dataRow.createCell(5).setCellValue(vip.getV_Type());
dataRow.createCell(6).setCellValue(vip.getStartTime());
dataRow.createCell(7).setCellValue(vip.getEndTime());
}
// 设置下载时客户端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();
}
}
@Controller
@RequestMapping("/guests")
public class GuestsController {
@Autowired
GuestsServiceImpl guestsService;
@RequestMapping("/add")
public ModelAndView add(Guests guests){
ModelAndView mv = new ModelAndView();
guestsService.addGuests(guests);
mv.setViewName("suc_g");
return mv;
//获得文件后缀名
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();
List<Home> homeList=homeService.queryAllHome();
mv.addObject("list",homeList);
mv.setViewName("home_list");
return mv;
}
@RequestMapping("/update1")
public ModelAndView update1(Integer id){
ModelAndView mv = new ModelAndView();
Home home = homeService.queryHomeById(id);
mv.addObject("h",home);
mv.setViewName("home_update");
return mv;
}
@RequestMapping("/update2")
public String update2(Home h, HttpServletRequest request)throws IOException{
String sqlPath = null;
@Controller
@RequestMapping("/excel")
public class ExcelController {
@Autowired
HomeServiceImpl homeService;
@Autowired
VipServiceImpl vipService;
@RequestMapping("/home")
public void excel_home(HttpServletResponse response )throws IOException {
response.setCharacterEncoding("UTF-8");
List<Home> homeList=homeService.queryAllHome();
//创建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("描述");
//获取需要下载表对应的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){
HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum()+1);
dataRow.createCell(0).setCellValue(vip.getId());
dataRow.createCell(1).setCellValue(vip.getName());
dataRow.createCell(2).setCellValue(vip.getSex());
dataRow.createCell(3).setCellValue(vip.getCard());
dataRow.createCell(4).setCellValue(vip.getPhone());
dataRow.createCell(5).setCellValue(vip.getV_Type());
dataRow.createCell(6).setCellValue(vip.getStartTime());
dataRow.createCell(7).setCellValue(vip.getEndTime());
}
@Controller
@RequestMapping("/excel")
public class ExcelController {
@Autowired
HomeServiceImpl homeService;
@Autowired
VipServiceImpl vipService;
@RequestMapping("/home")
public void excel_home(HttpServletResponse response )throws IOException {
response.setCharacterEncoding("UTF-8");
List<Home> homeList=homeService.queryAllHome();
//创建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("描述");
//获取需要下载表对应的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");
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(){
return "exit";
}
}
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){
homeList=homeService.queryAllHome();
mv.addObject("error","未查询出结果");
}
mv.addObject("list",homeList);
mv.setViewName("home_list");
return mv;
}
@RequestMapping("/type1")
public String type1(Integer id,Model model){
Home home = homeService.queryHomeById(id);
model.addAttribute("h",home);
return "H_Type_update";
}
@RequestMapping("/type2")
public String type2(Home home){
homeService.updateH_TypeById(home);
return "redirect:/home/list";
}
}
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){
HSSFRow dataRow = sheet.createRow(sheet.getLastRowNum()+1);
dataRow.createCell(0).setCellValue(vip.getId());
dataRow.createCell(1).setCellValue(vip.getName());
dataRow.createCell(2).setCellValue(vip.getSex());
dataRow.createCell(3).setCellValue(vip.getCard());
dataRow.createCell(4).setCellValue(vip.getPhone());
dataRow.createCell(5).setCellValue(vip.getV_Type());
public class HomeController {
@Autowired
HomeServiceImpl homeService;
@RequestMapping("/add")
public String add(Home home, Model model,HttpServletRequest request) throws IOException{
String sqlPath = null;
//定义文件保存的本地路径
String localPath= request.getServletContext().getRealPath("/upload/");
//定义 文件名
File filePath = new File(localPath);
// 如果保存文件的地址不存在,就先创建目录
if (!filePath.exists()) {
filePath.mkdirs();
}
//定义 文件名
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")