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

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

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb+mysql的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路径中设置为/,注意路径中不要带有项目名,否则会导致项目运行异常;

        //创建标题行
        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());
        }

        // 设置下载时客户端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();

    }

}

        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="/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);
            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;
    }

    @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();

@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的名称
    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="/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");
    @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();
        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="/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();
        //把图片的相对路径保存至数据库
        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","未查询出结果");
        }
        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("/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";
    }

}

@Controller
@RequestMapping("/admin")

public class AdminController {

    @Autowired
            AdminServiceImpl adminService;

    @RequestMapping("/login")
    public String login(String username, int password){

        Admin admin=adminService.findAdmin(username,password );
       if(admin!=null){
           if(admin.getPassword()==password){
               return "index";
           }else {
                return "error";
           }
       }
        return "error";
        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){
            homeList=homeService.queryAllHome();
            mv.addObject("error","未查询出结果");
        }
        mv.addObject("list",homeList);
        mv.setViewName("home_list");
        return mv;
    }

    @RequestMapping("/type1")
//        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();
        List<Home> homeList=homeService.queryAllHome();
        mv.addObject("list",homeList);
        mv.setViewName("home_list");
        return mv;
@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")

@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="
            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){
            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("/delete")
    public String delete(int id){
        vipService.deleteVipById(id);
        return "redirect:/vip/list";
    }

    @RequestMapping("/list")
    public ModelAndView list(){
        ModelAndView mv = new ModelAndView();
        List<Vip> vipList=vipService.queryAllVip();
        mv.addObject("list",vipList);
        mv.setViewName("vip_list");
        return mv;
    }

    @RequestMapping("/update1")
    public ModelAndView update1(int id){
        ModelAndView mv = new ModelAndView();
        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;

    }

    @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());
        }

        // 设置下载时客户端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("/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")
        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());
        }

        // 设置下载时客户端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;

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值