网易首页 > 网易号 > 正文 申请入驻

Java项目:酒店预定管理系统(java+JDBC+jsp+servlet+Mysql)

0
分享至

jsp+servlet+mysql实现的酒店管理系统,后台没有用到框架,用的是基础的servlet,前端用了一个仿win10的界面模板和layui前端框架,界面非常漂亮大气。

主要实现的功能有:管理员登录、楼层管理、房型管理、房间管理、预定管理、入住管理、查看账单、日志管理、用户管理等,所有管理列表页面都提供了导出到excel的功能。

酒店信息控制层:

* @Author: yy

* @Description: TODO(酒店信息)

@Controller

@RequestMapping("/hotels")

public class HotelController {

@Autowired

private IHotelService hotelService;

@Autowired

private IUserService iUserService;

//根据hid查看已拥有的房型

@RequestMapping("/findRooms.do")

public ModelAndView findRooms(Integer hid)throws Exception{

ModelAndView mv = new ModelAndView();

List

list = hotelService.findDetail(hid);

mv.addObject("room",list);

mv.setViewName("hotel-room-remove");

return mv;

//移除已拥有的房型

@RequestMapping("/removeRoom.do")

public String removeRoom(@RequestParam(name = "hid") Integer hid, @RequestParam(name = "ids") int[] ids)throws Exception{

hotelService.removeRoom(hid,ids);

return "redirect:findAll.do";

//根据hid查看未拥有的房型

@RequestMapping("/findOtherRooms.do")

public ModelAndView findOtherRooms(Integer hid)throws Exception{

ModelAndView mv = new ModelAndView();

Hotel hotel = hotelService.findByHid(hid);

mv.addObject("hotel",hotel);

List

list = hotelService.findOtherRooms(hid);

mv.addObject("room",list);

mv.setViewName("hotel-room-add");

return mv;

//添加未拥有的房型

@RequestMapping("/addRoom.do")

public String addRoom(@RequestParam(name = "hid") Integer hid, @RequestParam(name = "ids") int[] ids,@RequestParam(name = "prices")String[] prices)throws Exception{

List list = new ArrayList();

for (int i=0;i

if (prices[i]!=""){

list.add(Double.valueOf(prices[i]));

if (ids.length==list.size()){

hotelService.addRoom(hid,ids,list);

return "redirect:findAll.do";

//查看酒店房型详情

@RequestMapping("/findByUid.do")

public ModelAndView findByUid(Integer hid)throws Exception{

ModelAndView mv = new ModelAndView();

Hotel hotel = hotelService.findByHid(hid);

mv.addObject("hotel",hotel);

List

hoteldetail = hotelService.findDetail(hid);

mv.addObject("details",hoteldetail);

mv.setViewName("hotel-detail");

return mv;

//新增酒店

@RequestMapping("/findUsers.do")

public ModelAndView findUsers() throws Exception{

List

list = hotelService.findUsers();

ModelAndView mv = new ModelAndView();

mv.addObject("users",list);

mv.setViewName("hotel-add");

return mv;

@RequestMapping("/save.do")

public String save(Hotel hotel) throws Exception{

if (hotel.getHimageFile()!=null){

String filename = Upload.uploadImg(HIMAGE,hotel.getHimageFile());

hotel.setHimage("img/hotel/"+filename);

hotelService.save(hotel);

return "redirect:findAll.do";

//删除酒店

@RequestMapping("/delete.do")

public String delete(Integer hid) throws Exception {

hotelService.delete(hid);

return "redirect:findAll.do";

//修改酒店信息

@RequestMapping("/findU.do")

public ModelAndView findU(Integer hid) throws Exception{

ModelAndView mv = new ModelAndView();

Hotel hotel = hotelService.findByHid(hid);

mv.addObject("hotel",hotel);

List

list = iUserService.findAll(1,100,"%%");

mv.addObject("UList",list);

mv.setViewName("hotel-update");

return mv;

@RequestMapping("/update.do")

public String update(Hotel hotel) throws Exception{

if (hotel.getHimageFile().getSize()!=0&&hotel.getHimageFile()!=null){//修改过图片

String filename = Upload.uploadImg(HIMAGE,hotel.getHimageFile());

hotel.setHimage("img/hotel/"+filename);

hotelService.update(hotel);

}else{//未修改图片

hotelService.update(hotel);

return "redirect:findAll.do";

//查询所有订单

@RequestMapping("/findAll.do")

public ModelAndView findAll(

@RequestParam(name = "page",defaultValue = "1")Integer page,

@RequestParam(name = "size",defaultValue = "10")Integer size,

@RequestParam(name = "search",defaultValue = "")String search

) throws Exception{

ModelAndView mv = new ModelAndView();

List

list = hotelService.findAll(page,size,"%"+search+"%");

PageInfo pageInfo = new PageInfo(list);

mv.addObject("pageInfo",pageInfo);

mv.setViewName("hotel-list");

return mv;

房型管理控制层:

* @Author: yy

* @Description: TODO(房型管理)

@Controller

@RequestMapping("/rooms")

public class RoomController {

@Autowired

private IHoteltypeService hoteltypeService;

//新增房型

@RequestMapping("/save.do")

@PreAuthorize("hasAnyAuthority('/rooms/save.do')")

public String save(Hoteltype hoteltype) throws Exception{

hoteltypeService.save(hoteltype);

return "redirect:findAll.do";

//删除分类

@RequestMapping("/delete.do")

@PreAuthorize("hasAnyAuthority('/rooms/delete.do')")

public String delete(Integer tid) throws Exception{

hoteltypeService.delete(tid);

return "redirect:findAll.do";

//查询所有房型

@RequestMapping("/findAll.do")

@PreAuthorize("hasAnyAuthority('/rooms/findAll.do')")

public ModelAndView findAll(

@RequestParam(name = "page",defaultValue = "1") Integer page,

@RequestParam(name = "size",defaultValue = "10") Integer size,

@RequestParam(name = "search",defaultValue = "") String search

) throws Exception{

ModelAndView mv = new ModelAndView();

List

list = hoteltypeService.findAll(page,size,"%"+search+"%");

PageInfo pageInfo = new PageInfo(list);

mv.addObject("pageInfo",pageInfo);

mv.setViewName("room-list");

return mv;

用户操作控制层:

* @Author: yy

* @Description: TODO(用户操作)

@Controller

@RequestMapping("/users")

public class UserController {

@Autowired

private IUserService userService;

//给用户添加角色

@RequestMapping("/addRoleToUser.do")

@PreAuthorize("hasAnyAuthority('/users/addRoleToUser.do')")

public String addRoleToUser(@RequestParam(name = "userId", required = true) Integer userId, @RequestParam(name = "ids", required = true) int[] roleIds) throws Exception {

userService.addRoleToUser(userId, roleIds);

return "redirect:findAll.do";

//查询用户以及用户可以添加的角色

@RequestMapping("/findUserByIdAndAllRole.do")

@PreAuthorize("hasAnyAuthority('/users/findUserByIdAndAllRole.do')")

public ModelAndView findUserByIdAndAllRole(@RequestParam(name = "id", required = true) Integer uid) throws Exception {

ModelAndView mv = new ModelAndView();

//1.根据用户id查询用户

User user = userService.findByUid(uid);

//2.根据用户id查询可以添加的角色

List

otherRoles = userService.findOtherRoles(uid);

mv.addObject("user", user);

mv.addObject("roleList", otherRoles);

mv.setViewName("user-role-add");

return mv;

//查询用户拥有的角色

@RequestMapping("/findRoleByUserId.do")

@PreAuthorize("hasAnyAuthority('/users/findRoleByUserId.do')")

public ModelAndView findRoleByUserId(Integer userId) throws Exception{

ModelAndView mv = new ModelAndView();

User user = userService.findByUid(userId);

List

roleList = userService.findRoleByUserId(userId);

mv.addObject("user", user);

mv.addObject("roleList", roleList);

mv.setViewName("user-role-rmove");

return mv;

//移除用户指定的角色

@RequestMapping("/removeRole.do")

@PreAuthorize("hasAnyAuthority('/users/removeRole.do')")

public String removeRole( @RequestParam(name = "userId") Integer userId, @RequestParam(name = "ids") int[] roleIds) throws Exception{

userService.removeRole(userId,roleIds);

return "redirect:findAll.do";

//添加用户

@RequestMapping("/save.do")

@PreAuthorize("hasAnyAuthority('/users/save.do')")

public String save(User user) throws Exception {

userService.save(user);

return "redirect:findAll.do";

//删除用户,设置status=0

@RequestMapping("/delete.do")

@PreAuthorize("hasAnyAuthority('/users/delete.do')")

public String delete(Integer uid) throws Exception{

userService.delete(uid);

return "redirect:findAll.do";

//修改用户

@RequestMapping("/findU.do")

@PreAuthorize("hasAnyAuthority('/users/findU.do')")

public ModelAndView findU(Integer uid) throws Exception {

ModelAndView mv = new ModelAndView();

User user = userService.findByUid(uid);

mv.addObject("user",user);

mv.setViewName("user-update");

return mv;

@RequestMapping("/update.do")

@PreAuthorize("hasAnyAuthority('/users/update.do')")

public String update(User user) throws Exception{

userService.update(user);

return "redirect:findAll.do";

//根据uid查询用户

@RequestMapping("/findByUid.do")

@PreAuthorize("hasAnyAuthority('/users/findByUid.do')")

public ModelAndView findByUid(Integer uid) throws Exception {

ModelAndView mv = new ModelAndView();

User user = userService.findByUid(uid);

mv.addObject("user", user);

mv.setViewName("user-details");

return mv;

//查询用户相关信息

@RequestMapping("/findAll.do")

@PreAuthorize("hasAnyAuthority('/users/findAll.do')")

public ModelAndView findAll(

@RequestParam(name="page",required = true, defaultValue = "1") Integer page,

@RequestParam(name="size",required = true, defaultValue = "6") Integer size,

@RequestParam(name="username",required = true, defaultValue = "") String username

) throws Exception{

ModelAndView mv = new ModelAndView();

List

userList = userService.findAll(page,size,"%"+username+"%");

PageInfo pageInfo = new PageInfo(userList);

mv.addObject("pageInfo",pageInfo);

mv.setViewName("user-list");

return mv;

特别声明:以上内容(如有图片或视频亦包括在内)为自媒体平台“网易号”用户上传并发布,本平台仅提供信息存储服务。

Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.

相关推荐
热点推荐
海尔、美的、格力回应欧洲空调需求激增

海尔、美的、格力回应欧洲空调需求激增

中国能源网
2026-06-30 09:44:04
iPhone18 Pro遭泄密!照片、零部件、供应商信息被挂暗网,此前刚把印度推成生产基地

iPhone18 Pro遭泄密!照片、零部件、供应商信息被挂暗网,此前刚把印度推成生产基地

红星新闻
2026-06-30 14:19:20
160架战斗机就位 2000枚导弹下发 1400名空军飞行员等候战斗令

160架战斗机就位 2000枚导弹下发 1400名空军飞行员等候战斗令

聚峰军评
2026-06-30 13:01:28
楼上泼我家3年脏水,他儿考飞行员,我带15份录音证明送航司纪检

楼上泼我家3年脏水,他儿考飞行员,我带15份录音证明送航司纪检

千秋文化
2026-06-27 19:40:09
2026高考惊现“神仙卷面”!英文字迹像打印体,阅卷老师:高分

2026高考惊现“神仙卷面”!英文字迹像打印体,阅卷老师:高分

音乐时光的娱乐
2026-06-30 09:05:34
周光磊接受纪律审查和监察调查

周光磊接受纪律审查和监察调查

贵阳网
2026-06-30 10:11:00
人民日报提醒:酸奶、泡菜、豆豉,这些发酵食物正在重塑肠道菌群

人民日报提醒:酸奶、泡菜、豆豉,这些发酵食物正在重塑肠道菌群

肠菌科普
2026-06-29 18:00:11
国内最大沙漠发洪水,这世界越来越“古怪”

国内最大沙漠发洪水,这世界越来越“古怪”

南风窗
2026-06-29 13:25:18
罗永浩:我也不喜欢韩红说的“走个面儿”,但突然对她喊打喊杀,太流氓了

罗永浩:我也不喜欢韩红说的“走个面儿”,但突然对她喊打喊杀,太流氓了

观察者网
2026-06-30 16:37:17
涉嫌严重违纪违法,邓铭波被查

涉嫌严重违纪违法,邓铭波被查

中国基金报
2026-06-30 09:59:45
世界杯“点球之王”爆冷出局!德国曾在12码罚球点“打遍群雄无敌手”

世界杯“点球之王”爆冷出局!德国曾在12码罚球点“打遍群雄无敌手”

上游新闻
2026-06-30 13:32:37
姜萍再登热搜!涟水企业家再访姜萍家,网传其已在苏州某高校就读

姜萍再登热搜!涟水企业家再访姜萍家,网传其已在苏州某高校就读

火山詩话
2026-06-30 11:34:28
以色列防长:若伊朗攻击以色列领土将发动独立军事行动,穆杰塔巴已被列入死亡名单

以色列防长:若伊朗攻击以色列领土将发动独立军事行动,穆杰塔巴已被列入死亡名单

红星新闻
2026-06-30 13:57:26
悲情?荷兰近3届世界杯均在点球战被淘汰出局!92年12次参赛仍0冠

悲情?荷兰近3届世界杯均在点球战被淘汰出局!92年12次参赛仍0冠

我爱英超
2026-06-30 11:58:50
热议德国爆冷:德国失去了祖传风格,是“娘炮”在踢球

热议德国爆冷:德国失去了祖传风格,是“娘炮”在踢球

懂球帝
2026-06-30 09:45:08
未来5年,孩子上学有这些大变化!

未来5年,孩子上学有这些大变化!

安徽发布
2026-06-30 08:17:59
魏敏芝现状:在美国当导演,全家定居夏威夷,如今40岁胖到不敢认

魏敏芝现状:在美国当导演,全家定居夏威夷,如今40岁胖到不敢认

白面书誏
2026-06-29 21:16:24
“老登”变“小登”市值猛涨1700亿!京东方A创18年新高,仅次于07年大牛市时期,95万股民狂欢,400亿天量成交创历史记录

“老登”变“小登”市值猛涨1700亿!京东方A创18年新高,仅次于07年大牛市时期,95万股民狂欢,400亿天量成交创历史记录

金融界
2026-06-30 14:54:23
明天三场世界杯大胆预测:法国挪威获胜,厄瓜多尔有望掀翻东道主

明天三场世界杯大胆预测:法国挪威获胜,厄瓜多尔有望掀翻东道主

宝哥精彩赛事
2026-06-30 14:48:25
女子吃螺蛳粉吃出一条蛇,事发后工作人员直接端走螺蛳粉倒掉,涉事摊主发文致歉

女子吃螺蛳粉吃出一条蛇,事发后工作人员直接端走螺蛳粉倒掉,涉事摊主发文致歉

大风新闻
2026-06-30 14:23:14
2026-06-30 18:48:49
职坐标在线
职坐标在线
一站式IT培训就业服务平台
337文章数 4关注度
往期回顾 全部

财经要闻

韩国万亿"芯"基建:存储能否成AI时代油田

头条要闻

无人机攻防正酣 乌克兰却在此时给俄罗斯出了个难题

头条要闻

无人机攻防正酣 乌克兰却在此时给俄罗斯出了个难题

体育要闻

大热倒灶压力给到法国 王楚揭法国队隐患

娱乐要闻

韩红称要退出公益,多位名人挽留

科技要闻

iPhone18 Pro遭泄密!印度代工商惹祸

汽车要闻

奇瑞风云A9探店 五个理由一定来看看

态度原创

亲子
教育
家居
公开课
军事航空

亲子要闻

宝蓝画完画不洗手就去吃饭,被爸爸拉着去洗手不准吃东西。

教育要闻

2所高校,宣布延长博士生学制!

家居要闻

传奇筑 日常诗

公开课

李玫瑾:为什么性格比能力更重要?

军事要闻

以色列防长:穆杰塔巴已被列入死亡名单

无障碍浏览 进入关怀版