Java毕业设计实战之养老院管理系统的实现

运行环境:

JDK1.8、tomcat8、eclipse、mysql5.6、Navicat

功能实现:

用户: 用户名,登录密码,姓名,性别,出生日期,用户照片,联系电话,邮箱,家庭地址,注册时间

老人: 老人编号,姓名,性别,年龄,老人照片,老人介绍,登记用户,登记时间

房间类型: 房间类型id,房间类型名称

房间: 房间编号,房间类型,房间名称,房间主图,房间价格,房间详情,房间状态

订单: 订单编号,入住房间,入住老人,入住日期,入住时间,订单总金额,订单状态,订单费用明细,订单时间

老人看护: 记录id,信息类别,信息标题,信息内容,发布时间

接待: 接待记录id,接待类别,接待主题,接待内容,接待日期

部门: 部门编号,部门名称,成立日期,负责人

员工: 用户名,登录密码,所在部门,姓名,性别,出生日期,员工照片,联系电话,家庭地址

工资: 工资id,员工,工资年份,工资月份,工资金额,发放日期,工资备注

用户管理控制层:

//UserInfo管理控制层
@Controller
@RequestMapping("/UserInfo")
public class UserInfoController extends BaseController {

    /*业务层对象*/
    @Resource UserInfoService userInfoService;

	@InitBinder("userInfo")
	public void initBinderUserInfo(WebDataBinder binder) {
		binder.setFieldDefaultPrefix("userInfo.");
	}
	/*跳转到添加UserInfo视图*/
	@RequestMapping(value = "/add", method = RequestMethod.GET)
	public String add(Model model,HttpServletRequest request) throws Exception {
		model.addAttribute(new UserInfo());
		return "UserInfo_add";
	}

	/*客户端ajax方式提交添加用户信息*/
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public void add(@Validated UserInfo userInfo, BindingResult br,
			Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		String message = "";
		boolean success = false;
		if (br.hasErrors()) {
			message = "输入信息不符合要求!";
			writeJsonResponse(response, success, message);
			return ;
		}
		if(userInfoService.getUserInfo(userInfo.getUser_name()) != null) {
			message = "用户名已经存在!";
			writeJsonResponse(response, success, message);
			return ;
		}
		try {
			userInfo.setUserPhoto(this.handlePhotoUpload(request, "userPhotoFile"));
		} catch(UserException ex) {
			message = "图片格式不正确!";
			writeJsonResponse(response, success, message);
			return ;
		}
        userInfoService.addUserInfo(userInfo);
        message = "用户添加成功!";
        success = true;
        writeJsonResponse(response, success, message);
	}
	/*ajax方式按照查询条件分页查询用户信息*/
	@RequestMapping(value = { "/list" }, method = {RequestMethod.GET,RequestMethod.POST})
	public void list(String user_name,String name,String birthDate,String telephone,Integer page,Integer rows, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		if (page==null || page == 0) page = 1;
		if (user_name == null) user_name = "";
		if (name == null) name = "";
		if (birthDate == null) birthDate = "";
		if (telephone == null) telephone = "";
		if(rows != 0)userInfoService.setRows(rows);
		List<UserInfo> userInfoList = userInfoService.queryUserInfo(user_name, name, birthDate, telephone, page);
	    /*计算总的页数和总的记录数*/
	    userInfoService.queryTotalPageAndRecordNumber(user_name, name, birthDate, telephone);
	    /*获取到总的页码数目*/
	    int totalPage = userInfoService.getTotalPage();
	    /*当前查询条件下总记录数*/
	    int recordNumber = userInfoService.getRecordNumber();
        response.setContentType("text/json;charset=UTF-8");
		PrintWriter out = response.getWriter();
		//将要被返回到客户端的对象
		JSONObject jsonObj=new JSONObject();
		jsonObj.accumulate("total", recordNumber);
		JSONArray jsonArray = new JSONArray();
		for(UserInfo userInfo:userInfoList) {
			JSONObject jsonUserInfo = userInfo.getJsonObject();
			jsonArray.put(jsonUserInfo);
		}
		jsonObj.accumulate("rows", jsonArray);
		out.println(jsonObj.toString());
		out.flush();
		out.close();
	}

	/*ajax方式按照查询条件分页查询用户信息*/
	@RequestMapping(value = { "/listAll" }, method = {RequestMethod.GET,RequestMethod.POST})
	public void listAll(HttpServletResponse response) throws Exception {
		List<UserInfo> userInfoList = userInfoService.queryAllUserInfo();
        response.setContentType("text/json;charset=UTF-8");
		PrintWriter out = response.getWriter();
		JSONArray jsonArray = new JSONArray();
		for(UserInfo userInfo:userInfoList) {
			JSONObject jsonUserInfo = new JSONObject();
			jsonUserInfo.accumulate("user_name", userInfo.getUser_name());
			jsonUserInfo.accumulate("name", userInfo.getName());
			jsonArray.put(jsonUserInfo);
		}
		out.println(jsonArray.toString());
		out.flush();
		out.close();
	}

	/*前台按照查询条件分页查询用户信息*/
	@RequestMapping(value = { "/frontlist" }, method = {RequestMethod.GET,RequestMethod.POST})
	public String frontlist(String user_name,String name,String birthDate,String telephone,Integer currentPage, Model model, HttpServletRequest request) throws Exception  {
		if (currentPage==null || currentPage == 0) currentPage = 1;
		if (user_name == null) user_name = "";
		if (name == null) name = "";
		if (birthDate == null) birthDate = "";
		if (telephone == null) telephone = "";
		List<UserInfo> userInfoList = userInfoService.queryUserInfo(user_name, name, birthDate, telephone, currentPage);
	    /*计算总的页数和总的记录数*/
	    userInfoService.queryTotalPageAndRecordNumber(user_name, name, birthDate, telephone);
	    /*获取到总的页码数目*/
	    int totalPage = userInfoService.getTotalPage();
	    /*当前查询条件下总记录数*/
	    int recordNumber = userInfoService.getRecordNumber();
	    request.setAttribute("userInfoList",  userInfoList);
	    request.setAttribute("totalPage", totalPage);
	    request.setAttribute("recordNumber", recordNumber);
	    request.setAttribute("currentPage", currentPage);
	    request.setAttribute("user_name", user_name);
	    request.setAttribute("name", name);
	    request.setAttribute("birthDate", birthDate);
	    request.setAttribute("telephone", telephone);
		return "UserInfo/userInfo_frontquery_result";
	}

     /*前台查询UserInfo信息*/
	@RequestMapping(value="/{user_name}/frontshow",method=RequestMethod.GET)
	public String frontshow(@PathVariable String user_name,Model model,HttpServletRequest request) throws Exception {
		/*根据主键user_name获取UserInfo对象*/
        UserInfo userInfo = userInfoService.getUserInfo(user_name);

        request.setAttribute("userInfo",  userInfo);
        return "UserInfo/userInfo_frontshow";
	}

	/*ajax方式显示用户修改jsp视图页*/
	@RequestMapping(value="/{user_name}/update",method=RequestMethod.GET)
	public void update(@PathVariable String user_name,Model model,HttpServletRequest request,HttpServletResponse response) throws Exception {
        /*根据主键user_name获取UserInfo对象*/
        UserInfo userInfo = userInfoService.getUserInfo(user_name);

        response.setContentType("text/json;charset=UTF-8");
        PrintWriter out = response.getWriter();
		//将要被返回到客户端的对象
		JSONObject jsonUserInfo = userInfo.getJsonObject();
		out.println(jsonUserInfo.toString());
		out.flush();
		out.close();
	}

	/*ajax方式更新用户信息*/
	@RequestMapping(value = "/{user_name}/update", method = RequestMethod.POST)
	public void update(@Validated UserInfo userInfo, BindingResult br,
			Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		String message = "";
    	boolean success = false;
		if (br.hasErrors()) {
			message = "输入的信息有错误!";
			writeJsonResponse(response, success, message);
			return;
		}
		String userPhotoFileName = this.handlePhotoUpload(request, "userPhotoFile");
		if(!userPhotoFileName.equals("upload/NoImage.jpg"))userInfo.setUserPhoto(userPhotoFileName); 

		try {
			userInfoService.updateUserInfo(userInfo);
			message = "用户更新成功!";
			success = true;
			writeJsonResponse(response, success, message);
		} catch (Exception e) {
			e.printStackTrace();
			message = "用户更新失败!";
			writeJsonResponse(response, success, message);
		}
	}
    /*删除用户信息*/
	@RequestMapping(value="/{user_name}/delete",method=RequestMethod.GET)
	public String delete(@PathVariable String user_name,HttpServletRequest request) throws UnsupportedEncodingException {
		  try {
			  userInfoService.deleteUserInfo(user_name);
	            request.setAttribute("message", "用户删除成功!");
	            return "message";
	        } catch (Exception e) {
	            e.printStackTrace();
	            request.setAttribute("error", "用户删除失败!");
				return "error";

	        }

	}

	/*ajax方式删除多条用户记录*/
	@RequestMapping(value="/deletes",method=RequestMethod.POST)
	public void delete(String user_names,HttpServletRequest request,HttpServletResponse response) throws IOException, JSONException {
		String message = "";
    	boolean success = false;
        try {
        	int count = userInfoService.deleteUserInfos(user_names);
        	success = true;
        	message = count + "条记录删除成功";
        	writeJsonResponse(response, success, message);
        } catch (Exception e) {
            //e.printStackTrace();
            message = "有记录存在外键约束,删除失败";
            writeJsonResponse(response, success, message);
        }
	}

	/*按照查询条件导出用户信息到Excel*/
	@RequestMapping(value = { "/OutToExcel" }, method = {RequestMethod.GET,RequestMethod.POST})
	public void OutToExcel(String user_name,String name,String birthDate,String telephone, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
        if(user_name == null) user_name = "";
        if(name == null) name = "";
        if(birthDate == null) birthDate = "";
        if(telephone == null) telephone = "";
        List<UserInfo> userInfoList = userInfoService.queryUserInfo(user_name,name,birthDate,telephone);
        ExportExcelUtil ex = new ExportExcelUtil();
        String _title = "UserInfo信息记录";
        String[] headers = { "用户名","姓名","性别","出生日期","用户照片","联系电话","邮箱","注册时间"};
        List<String[]> dataset = new ArrayList<String[]>();
        for(int i=0;i<userInfoList.size();i++) {
        	UserInfo userInfo = userInfoList.get(i);
        	dataset.add(new String[]{userInfo.getUser_name(),userInfo.getName(),userInfo.getGender(),userInfo.getBirthDate(),userInfo.getUserPhoto(),userInfo.getTelephone(),userInfo.getEmail(),userInfo.getRegTime()});
        }
        /*
        OutputStream out = null;
		try {
			out = new FileOutputStream("C://output.xls");
			ex.exportExcel(title,headers, dataset, out);
		    out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		*/
		OutputStream out = null;//创建一个输出流对象
		try {
			out = response.getOutputStream();//
			response.setHeader("Content-disposition","attachment; filename="+"UserInfo.xls");//filename是下载的xls的名,建议最好用英文
			response.setContentType("application/msexcel;charset=UTF-8");//设置类型
			response.setHeader("Pragma","No-cache");//设置头
			response.setHeader("Cache-Control","no-cache");//设置头
			response.setDateHeader("Expires", 0);//设置日期头
			String rootPath = request.getSession().getServletContext().getRealPath("/");
			ex.exportExcel(rootPath,_title,headers, dataset, out);
			out.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try{
				if(out!=null){
					out.close();
				}
			}catch(IOException e){
				e.printStackTrace();
			}
		}
    }
}

管理员管理控制层:

@Controller
@SessionAttributes("username")
public class SystemController { 

	@Resource AdminService adminService;  

	@Resource UserInfoService userInfoService;  

	@RequestMapping(value="/login",method=RequestMethod.GET)
	public String login(Model model) {
		model.addAttribute(new Admin());
		return "login";
	}

	//前台用户登录
	@RequestMapping(value="/frontLogin",method=RequestMethod.POST)
	public void frontLogin(@RequestParam("userName")String userName,@RequestParam("password")String password,HttpServletResponse response,HttpSession session) throws Exception {
		boolean success = true;
		String msg = ""; 

		if (!userInfoService.checkLogin(userName, password)) {
			msg = userInfoService.getErrMessage();
			success = false;
		}
		if(success) {
			session.setAttribute("user_name", userName);
		}

        response.setContentType("text/json;charset=UTF-8");
        PrintWriter out = response.getWriter();
        //将要被返回到客户端的对象
        JSONObject json=new JSONObject();
        json.accumulate("success", success);
        json.accumulate("msg", msg);
        out.println(json.toString());
        out.flush();
        out.close();
	}

	@RequestMapping(value="/login",method=RequestMethod.POST)
	public void login(@Validated Admin admin,BindingResult br,Model model,HttpServletRequest request,HttpServletResponse response,HttpSession session) throws Exception {
		boolean success = true;
		String msg = "";
		if(br.hasErrors()) {
			msg = br.getAllErrors().toString();
			success = false;
		}
		if (!adminService.checkLogin(admin)) {
			msg = adminService.getErrMessage();
			success = false;
		}
		if(success) {
			session.setAttribute("username", admin.getUsername());
		}
        response.setContentType("text/json;charset=UTF-8");
        PrintWriter out = response.getWriter();
        //将要被返回到客户端的对象
        JSONObject json=new JSONObject();
        json.accumulate("success", success);
        json.accumulate("msg", msg);
        out.println(json.toString());
        out.flush();
        out.close();
	}

	@RequestMapping("/logout")
	public String logout(Model model,HttpSession session) {
		model.asMap().remove("username");
		session.invalidate();
		return "redirect:/login";
	}

	@RequestMapping(value="/changePassword",method=RequestMethod.POST)
	public String ChangePassword(String oldPassword,String newPassword,String newPassword2,HttpServletRequest request,HttpSession session) throws Exception {
		if(oldPassword.equals("")) throw new UserException("请输入旧密码!");
		if(newPassword.equals("")) throw new UserException("请输入新密码!");
		if(!newPassword.equals(newPassword2)) throw new UserException("两次新密码输入不一致"); 

		String username = (String)session.getAttribute("username");
		if(username == null) throw new UserException("session会话超时,请重新登录系统!");

		Admin admin = adminService.findAdminByUserName(username);
		if(!admin.getPassword().equals(oldPassword)) throw new UserException("输入的旧密码不正确!");

		try {
			adminService.changePassword(username,newPassword);
			request.setAttribute("message", java.net.URLEncoder.encode(
					"密码修改成功!", "GBK"));
			return "message";
		} catch (Exception e) {
			e.printStackTrace();
			request.setAttribute("error", java.net.URLEncoder
					.encode("密码修改失败!","GBK"));
			return "error";
		}
	}

}

房间管理控制层:

//Room管理控制层
@Controller
@RequestMapping("/Room")
public class RoomController extends BaseController {

    /*业务层对象*/
    @Resource RoomService roomService;

    @Resource RoomTypeService roomTypeService;
	@InitBinder("roomTypeObj")
	public void initBinderroomTypeObj(WebDataBinder binder) {
		binder.setFieldDefaultPrefix("roomTypeObj.");
	}
	@InitBinder("room")
	public void initBinderRoom(WebDataBinder binder) {
		binder.setFieldDefaultPrefix("room.");
	}
	/*跳转到添加Room视图*/
	@RequestMapping(value = "/add", method = RequestMethod.GET)
	public String add(Model model,HttpServletRequest request) throws Exception {
		model.addAttribute(new Room());
		/*查询所有的RoomType信息*/
		List<RoomType> roomTypeList = roomTypeService.queryAllRoomType();
		request.setAttribute("roomTypeList", roomTypeList);
		return "Room_add";
	}

	/*客户端ajax方式提交添加房间信息*/
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public void add(@Validated Room room, BindingResult br,
			Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		String message = "";
		boolean success = false;
		if (br.hasErrors()) {
			message = "输入信息不符合要求!";
			writeJsonResponse(response, success, message);
			return ;
		}
		if(roomService.getRoom(room.getRoomNo()) != null) {
			message = "房间编号已经存在!";
			writeJsonResponse(response, success, message);
			return ;
		}
		try {
			room.setMainPhoto(this.handlePhotoUpload(request, "mainPhotoFile"));
		} catch(UserException ex) {
			message = "图片格式不正确!";
			writeJsonResponse(response, success, message);
			return ;
		}
        roomService.addRoom(room);
        message = "房间添加成功!";
        success = true;
        writeJsonResponse(response, success, message);
	}
	/*ajax方式按照查询条件分页查询房间信息*/
	@RequestMapping(value = { "/list" }, method = {RequestMethod.GET,RequestMethod.POST})
	public void list(String roomNo,@ModelAttribute("roomTypeObj") RoomType roomTypeObj,String roomName,String roomState,Integer page,Integer rows, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		if (page==null || page == 0) page = 1;
		if (roomNo == null) roomNo = "";
		if (roomName == null) roomName = "";
		if (roomState == null) roomState = "";
		if(rows != 0)roomService.setRows(rows);
		List<Room> roomList = roomService.queryRoom(roomNo, roomTypeObj, roomName, roomState, page);
	    /*计算总的页数和总的记录数*/
	    roomService.queryTotalPageAndRecordNumber(roomNo, roomTypeObj, roomName, roomState);
	    /*获取到总的页码数目*/
	    int totalPage = roomService.getTotalPage();
	    /*当前查询条件下总记录数*/
	    int recordNumber = roomService.getRecordNumber();
        response.setContentType("text/json;charset=UTF-8");
		PrintWriter out = response.getWriter();
		//将要被返回到客户端的对象
		JSONObject jsonObj=new JSONObject();
		jsonObj.accumulate("total", recordNumber);
		JSONArray jsonArray = new JSONArray();
		for(Room room:roomList) {
			JSONObject jsonRoom = room.getJsonObject();
			jsonArray.put(jsonRoom);
		}
		jsonObj.accumulate("rows", jsonArray);
		out.println(jsonObj.toString());
		out.flush();
		out.close();
	}

	/*ajax方式按照查询条件分页查询房间信息*/
	@RequestMapping(value = { "/listAll" }, method = {RequestMethod.GET,RequestMethod.POST})
	public void listAll(HttpServletResponse response) throws Exception {
		List<Room> roomList = roomService.queryAllRoom();
        response.setContentType("text/json;charset=UTF-8");
		PrintWriter out = response.getWriter();
		JSONArray jsonArray = new JSONArray();
		for(Room room:roomList) {
			JSONObject jsonRoom = new JSONObject();
			jsonRoom.accumulate("roomNo", room.getRoomNo());
			jsonRoom.accumulate("roomName", room.getRoomName());
			jsonArray.put(jsonRoom);
		}
		out.println(jsonArray.toString());
		out.flush();
		out.close();
	}

	/*前台按照查询条件分页查询房间信息*/
	@RequestMapping(value = { "/frontlist" }, method = {RequestMethod.GET,RequestMethod.POST})
	public String frontlist(String roomNo,@ModelAttribute("roomTypeObj") RoomType roomTypeObj,String roomName,String roomState,Integer currentPage, Model model, HttpServletRequest request) throws Exception  {
		if (currentPage==null || currentPage == 0) currentPage = 1;
		if (roomNo == null) roomNo = "";
		if (roomName == null) roomName = "";
		if (roomState == null) roomState = "";
		List<Room> roomList = roomService.queryRoom(roomNo, roomTypeObj, roomName, roomState, currentPage);
	    /*计算总的页数和总的记录数*/
	    roomService.queryTotalPageAndRecordNumber(roomNo, roomTypeObj, roomName, roomState);
	    /*获取到总的页码数目*/
	    int totalPage = roomService.getTotalPage();
	    /*当前查询条件下总记录数*/
	    int recordNumber = roomService.getRecordNumber();
	    request.setAttribute("roomList",  roomList);
	    request.setAttribute("totalPage", totalPage);
	    request.setAttribute("recordNumber", recordNumber);
	    request.setAttribute("currentPage", currentPage);
	    request.setAttribute("roomNo", roomNo);
	    request.setAttribute("roomTypeObj", roomTypeObj);
	    request.setAttribute("roomName", roomName);
	    request.setAttribute("roomState", roomState);
	    List<RoomType> roomTypeList = roomTypeService.queryAllRoomType();
	    request.setAttribute("roomTypeList", roomTypeList);
		return "Room/room_frontquery_result";
	}

     /*前台查询Room信息*/
	@RequestMapping(value="/{roomNo}/frontshow",method=RequestMethod.GET)
	public String frontshow(@PathVariable String roomNo,Model model,HttpServletRequest request) throws Exception {
		/*根据主键roomNo获取Room对象*/
        Room room = roomService.getRoom(roomNo);

        List<RoomType> roomTypeList = roomTypeService.queryAllRoomType();
        request.setAttribute("roomTypeList", roomTypeList);
        request.setAttribute("room",  room);
        return "Room/room_frontshow";
	}

	/*ajax方式显示房间修改jsp视图页*/
	@RequestMapping(value="/{roomNo}/update",method=RequestMethod.GET)
	public void update(@PathVariable String roomNo,Model model,HttpServletRequest request,HttpServletResponse response) throws Exception {
        /*根据主键roomNo获取Room对象*/
        Room room = roomService.getRoom(roomNo);

        response.setContentType("text/json;charset=UTF-8");
        PrintWriter out = response.getWriter();
		//将要被返回到客户端的对象
		JSONObject jsonRoom = room.getJsonObject();
		out.println(jsonRoom.toString());
		out.flush();
		out.close();
	}

	/*ajax方式更新房间信息*/
	@RequestMapping(value = "/{roomNo}/update", method = RequestMethod.POST)
	public void update(@Validated Room room, BindingResult br,
			Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		String message = "";
    	boolean success = false;
		if (br.hasErrors()) {
			message = "输入的信息有错误!";
			writeJsonResponse(response, success, message);
			return;
		}
		String mainPhotoFileName = this.handlePhotoUpload(request, "mainPhotoFile");
		if(!mainPhotoFileName.equals("upload/NoImage.jpg"))room.setMainPhoto(mainPhotoFileName); 

		try {
			roomService.updateRoom(room);
			message = "房间更新成功!";
			success = true;
			writeJsonResponse(response, success, message);
		} catch (Exception e) {
			e.printStackTrace();
			message = "房间更新失败!";
			writeJsonResponse(response, success, message);
		}
	}
    /*删除房间信息*/
	@RequestMapping(value="/{roomNo}/delete",method=RequestMethod.GET)
	public String delete(@PathVariable String roomNo,HttpServletRequest request) throws UnsupportedEncodingException {
		  try {
			  roomService.deleteRoom(roomNo);
	            request.setAttribute("message", "房间删除成功!");
	            return "message";
	        } catch (Exception e) {
	            e.printStackTrace();
	            request.setAttribute("error", "房间删除失败!");
				return "error";

	        }

	}

	/*ajax方式删除多条房间记录*/
	@RequestMapping(value="/deletes",method=RequestMethod.POST)
	public void delete(String roomNos,HttpServletRequest request,HttpServletResponse response) throws IOException, JSONException {
		String message = "";
    	boolean success = false;
        try {
        	int count = roomService.deleteRooms(roomNos);
        	success = true;
        	message = count + "条记录删除成功";
        	writeJsonResponse(response, success, message);
        } catch (Exception e) {
            //e.printStackTrace();
            message = "有记录存在外键约束,删除失败";
            writeJsonResponse(response, success, message);
        }
	}

	/*按照查询条件导出房间信息到Excel*/
	@RequestMapping(value = { "/OutToExcel" }, method = {RequestMethod.GET,RequestMethod.POST})
	public void OutToExcel(String roomNo,@ModelAttribute("roomTypeObj") RoomType roomTypeObj,String roomName,String roomState, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
        if(roomNo == null) roomNo = "";
        if(roomName == null) roomName = "";
        if(roomState == null) roomState = "";
        List<Room> roomList = roomService.queryRoom(roomNo,roomTypeObj,roomName,roomState);
        ExportExcelUtil ex = new ExportExcelUtil();
        String _title = "Room信息记录";
        String[] headers = { "房间编号","房间类型","房间名称","房间主图","房间价格","房间状态"};
        List<String[]> dataset = new ArrayList<String[]>();
        for(int i=0;i<roomList.size();i++) {
        	Room room = roomList.get(i);
        	dataset.add(new String[]{room.getRoomNo(),room.getRoomTypeObj().getTypeName(),room.getRoomName(),room.getMainPhoto(),room.getPrice() + "",room.getRoomState()});
        }
        /*
        OutputStream out = null;
		try {
			out = new FileOutputStream("C://output.xls");
			ex.exportExcel(title,headers, dataset, out);
		    out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		*/
		OutputStream out = null;//创建一个输出流对象
		try {
			out = response.getOutputStream();//
			response.setHeader("Content-disposition","attachment; filename="+"Room.xls");//filename是下载的xls的名,建议最好用英文
			response.setContentType("application/msexcel;charset=UTF-8");//设置类型
			response.setHeader("Pragma","No-cache");//设置头
			response.setHeader("Cache-Control","no-cache");//设置头
			response.setDateHeader("Expires", 0);//设置日期头
			String rootPath = request.getSession().getServletContext().getRealPath("/");
			ex.exportExcel(rootPath,_title,headers, dataset, out);
			out.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try{
				if(out!=null){
					out.close();
				}
			}catch(IOException e){
				e.printStackTrace();
			}
		}
    }
}

到此这篇关于Java毕业设计实战之养老院管理系统的实现的文章就介绍到这了,更多相关Java 养老院管理系统内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • Java毕业设计实战之教室预订管理系统的实现

    一.项目运行 环境配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持). 项目技术: Spring + SpringBoot+ mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等. 用户管理控制器: /** * 用户管理控制器 */ @RequestMapping("/user/") @Contr

  • Java毕业设计实战之共享租车信息管理系统的实现

    基于servlet+jsp+jdbc的后台管理系统,包含5个模块:汽车账户部管理.租车账户部管理.汽车信息管理表.租车记录表.租车租聘表.功能完整,均能实现增删查改. 运行环境: jdk8+tomcat8.5+mysql5.7+Eclipse 项目技术: servlet+jsp+jdbc+easyui+jquery       主页登陆注册业务: public class ForeServlet extends BaseForeServlet { /** * 显示主页 * * @param re

  • Java毕业设计实战之平行志愿管理系统的实现

    一.项目简述 本系统功能包括: 系统管理,招生计划,学生管理,录取结果,自动分配,调剂管理等等. 二.项目运行 环境配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持). 项目技术: Springboot + Maven + mybatis+ Vue 等等组成,B/S模式 + Maven管理等等. 学生管理控制层: @RestControlle

  • Java毕业设计实战之财务预算管理系统的实现

    一.项目简述 功能包括:实现公司对项目的管理. 二.项目运行 环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持) 项目技术: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等 用户信息控制层: /** * 用户信息控制层 */ @Controller

  • Java毕业设计实战之工作管理系统的实现

    前台用户和后台管理员两种角色: 前台用户功能有:发布兼职.发布帖子.查看公告.个人中心.投诉等. 后台管理员功能有:用户管理.兼职管理.帖子管理.聊天管理.广告管理.投诉管理.收藏管理.系统管理等. 运行环境:jdk1.8.tomcat7.0\8.5.Eclipse.Mysql5.x. 后台角色管理控制器: /** * 后台角色管理控制器 * @author yy * */ @RequestMapping("/admin/role") @Controller public class

  • Java毕业设计实战之在线高中考试系统的实现

    项目分为前台和后台,前台主要为学生角色.后台主要为管理员角色. 管理员添加试题和发布试卷,学生负责在线考试.在线查看成绩和错题记录列表等. 管理员功能有:年级管理.课程管理.试题管理.试卷管理.学生管理等. 运行环境:jdk1.8.mysql5.x.eclipse.tomcat8.5\7.0.maven3.5\3.6. 统一管理学生 教师 管理员信息: /** * 统一管理学生 教师 管理员信息 */ @RestController public class UserController { @

  • Java毕业设计实战之健身俱乐部管理系统的实现

    项目介绍: 基于jsp+mysql+Spring+mybatis的SSM健身房管理系统 运行环境: jdk 1.8 IDE环境: Eclipse,Myeclipse,IDEA都可以 tomcat环境: Tomcat 7.x,8.x,9.x版本均可,理论上Tomcat版本不是太老都可以. 硬件环境: windows 7/8/10 1G内存以上 主要功能说明: 管理员角色包含以下功能:登录页面,管理员首页,会员增删改查,教练增删改查,运动器材管理等功能. 用户角色包含以下功能:用户登录页面,用户首页

  • Java毕业设计实战之宠物医院与商城一体的系统的实现

    项目运行: 环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持) 项目技术: Springboot+ SpringMVC + MyBatis + Jsp + Html+ JavaScript + JQuery + Ajax + maven等等 宠物医院与商城一体的系统 后端管理员控制层: /** * 后端管理员控制层 */ @Controller @RequestMapping("/a

  • Java毕业设计实战之生活旅行分享平台的实现

    一.项目运行 环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持) 项目技术: Springboot+ SpringMVC + JPA+ Jsp + Html+ JavaScript + JQuery + Ajax + maven等等 评论业务控制器: /** * 评论控制器 * @author yy * */ @RestController @RequestMapping("/com

  • Java毕业设计实战之养老院管理系统的实现

    运行环境: JDK1.8.tomcat8.eclipse.mysql5.6.Navicat 功能实现: 用户: 用户名,登录密码,姓名,性别,出生日期,用户照片,联系电话,邮箱,家庭地址,注册时间 老人: 老人编号,姓名,性别,年龄,老人照片,老人介绍,登记用户,登记时间 房间类型: 房间类型id,房间类型名称 房间: 房间编号,房间类型,房间名称,房间主图,房间价格,房间详情,房间状态 订单: 订单编号,入住房间,入住老人,入住日期,入住时间,订单总金额,订单状态,订单费用明细,订单时间 老人

  • Java毕业设计实战之学生管理系统的实现

    一.项目简述 本系统功能包括: 学生管理,教师管理,课程管理,成绩管理,系统管理等等. 二.项目运行 环境配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持). 项目技术: Springboot + Maven + mybatis+ Vue 等等组成,B/S模式 + Maven管理等等. 学生管理控制层: @Controller @Reques

  • Java毕业设计实战项目之仓库管理系统的实现流程

    基于SSM框架的仓库管理系统 功能: 系统操作权限管理.系统提供基本的登入登出功能,同时系统包含两个角色:系统超级管理员和普通管理员,超级管理员具有最高的操作权限,而普通管理员仅具有最基本的操作权限,而且仅能操作自己被指派的仓库. 请求URL鉴权.对于系统使用者登陆后进行操作发送请求的URL,后台会根据当前用户的角色判断是否拥有请求该URL的权限. 基础数据信息管理.对包括:货物信息.供应商信息.客户信息.仓库信息在内的基础数据信息进行管理,提供的操作有:添加.删除.修改.条件查询.导出为Exc

  • Java毕业设计实战之药店信息管理系统的实现

    一.项目简述 环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持) 项目技术: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等 药品相关的controller: /** * 药品相关的controller */ @Controller @Request

  • Java毕业设计实战之图片展览馆管理系统的实现

    一.项目运行 环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持) 项目技术: Springboot+ SpringMVC + JPA+ Jsp + Html+ JavaScript + JQuery + Ajax + maven等等 订单服务: @WebServlet("/order/OrderServlet") public class OrderServlet exte

随机推荐