博主主頁:Java旅途
簡介:分享計算機(jī)知識、學(xué)習(xí)路線、系統(tǒng)源碼及教程
文末獲取源碼
一、項目介紹
酒店管理系統(tǒng)基于Spring+SpringMVC+Mybatis開發(fā),功能簡單,可用于畢設(shè)或者課程設(shè)計。
管理員功能如下:
- 房間管理
- 住客入住
- 住客管理
- 會員管理
- 登錄、修改密碼
- 數(shù)據(jù)導(dǎo)出
二、技術(shù)框架
- 后端:Spring,Springmvc,Mybatis
- 前端:layui
三、安裝教程
- 用idea打開項目
- 在idea中配置jdk環(huán)境
- 配置maven環(huán)境并下載依賴
- 配置tomcat8.0
- 新建數(shù)據(jù)庫,導(dǎo)入數(shù)據(jù)庫文件
- 在jdbc.properties文件中將數(shù)據(jù)庫賬號密碼改成自己本地的
- 啟動運行, 管理員賬號密碼 admin/123456
四、運行截圖
五、相關(guān)代碼
GuestController
package com.hotel.controller;
import com.hotel.pojo.Guests;
import com.hotel.service.GuestsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import java.util.ArrayList;
import java.util.List;
@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");
}
@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","未查詢出結(jié)果");
}
mv.addObject("list",guestsList);
mv.setViewName("guests_list");
return mv;
}
}
HomeController文章來源:http://www.zghlxwxcb.cn/news/detail-770901.html
package com.hotel.controller;
import com.hotel.pojo.Home;
import com.hotel.service.HomeServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@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="F:\\bysj2\\項目整理\\付費畢設(shè)\\103SSM的酒店管理系統(tǒng)\\源碼\\Hotel_Manage\\src\\main\\webapp\\upload\\";
//定義 文件名
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));
}
//把圖片的相對路徑保存至數(shù)據(jù)庫
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)throws IOException{
String sqlPath = null;
//定義文件保存的本地路徑
String localPath="F:\\bysj2\\項目整理\\付費畢設(shè)\\103SSM的酒店管理系統(tǒng)\\源碼\\Hotel_Manage\\src\\main\\webapp\\upload\\";
//定義 文件名
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));
}
//把圖片的相對路徑保存至數(shù)據(jù)庫
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){
homeList=homeService.queryAllHome();
mv.addObject("error","未查詢出結(jié)果");
}
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";
}
}
大家點贊、收藏、關(guān)注、評論啦 、????點開下方卡片????關(guān)注后回復(fù) 100 文章來源地址http://www.zghlxwxcb.cn/news/detail-770901.html
到了這里,關(guān)于Java項目:103SSM酒店管理系統(tǒng)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!