——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明









基于javaweb的JSP+Servlet酒店预定管理系统(java+jsp+bootstrap+servlet+mysql)
管理员:
admin 123456
注意:前台预定后,需要后台管理员审核通过,前台才能查询到预定信息
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| if(roomId!=null){ queryListByRoomId(req,resp); }else{ resp.setContentType("application/json;chartset=utf-8"); resp.getWriter().print(JSON.toJSONString(R.ok())); } break; default: query(req,resp); break; } }
public void queryListByRoomId(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String roomID=req.getParameter("roomId"); try { List<CommentInfo> list= commentInfoService.queryListByRoomID(Integer.parseInt(roomID)); resp.setContentType("application/json;chartset=utf-8"); Map map=new HashMap(); map.put("list",list); String jsons= JSON.toJSONString(map); resp.getWriter().print(jsons); } catch (SQLException throwables) { throwables.printStackTrace(); } }
public void query(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { List<RoomInfo> list=roomInfoService.queryRoomListByStatus(0); req.setAttribute("list",list); req.getRequestDispatcher("room.jsp").forward(req,resp); }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| */ public void query(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String currPage=req.getParameter("page"); String limit=req.getParameter("limit"); String content=req.getParameter("content")==null?null:req.getParameter("content"); if(currPage==null || "".equals(currPage.trim())){ currPage="1"; }
if(limit==null || "".equals(limit.trim())){ limit="10"; }
PageBean<RoomInfo> pageBean=null; try { pageBean = service.getPage(currPage,limit,content); } catch (SQLException throwables) { throwables.printStackTrace(); }
JsonObject object=new JsonObject(); object.setCode(0); object.setMsg(""); object.setCount(pageBean.getTotalCount()); object.setData(pageBean.getPageData());
resp.setContentType("application/json;chartset=utf-8"); String jsons= JSON.toJSONString(object); resp.getWriter().print(jsons); } }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| String password=req.getParameter("password"); service.updatePasswordByUserId(password,Integer.parseInt(id2)); resp.setContentType("application/json;chartset=utf-8"); resp.getWriter().print(JSON.toJSONString(R.ok())); break; case "delete": String ids=req.getParameter("ids"); List<String> idList= Arrays.asList(ids.split(",")); for(String id:idList){ service.deleteById(Integer.parseInt(id)); } resp.setContentType("application/json;chartset=utf-8"); resp.getWriter().print(JSON.toJSONString(R.ok())); break; case "queryId": String id=req.getParameter("id"); UserInfo info1= null; try { info1 = service.queryByID(Integer.parseInt(id)); } catch (SQLException throwables) { throwables.printStackTrace(); } req.setAttribute("info",info1); resp.setContentType("text/html;chartset=utf-8"); req.getRequestDispatcher("admin/user/update.jsp").forward(req,resp); break; case "update": UserInfo roomInfo=getValues(req); boolean bs=service.updateInfo(roomInfo); resp.setContentType("application/json;chartset=utf-8"); String jsons2=JSON.toJSONString(R.fail("修改失败了...")); if(bs){ jsons2=JSON.toJSONString(R.ok()); } resp.getWriter().print(jsons2); break; default: query(req,resp); break; }
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
@WebServlet("/commentServlet") public class CommentServlet extends HttpServlet {
CommentInfoService service=new CommentInfoServiceImpl(); @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String flag=req.getParameter("flag")==null?"":req.getParameter("flag"); switch (flag){ case "delete": String ids=req.getParameter("ids"); List<String> idList= Arrays.asList(ids.split(",")); for(String id:idList){ service.deleteById(Integer.parseInt(id)); } resp.setContentType("application/json;chartset=utf-8"); resp.getWriter().print(JSON.toJSONString(R.ok())); break; default: query(req,resp); break; }
}
public void query(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String currPage=req.getParameter("page"); String limit=req.getParameter("limit");
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| List <String> listName=new ArrayList<>(); List <Integer> listData=new ArrayList<>(); for(DataCount dataCount:dataCountList){ listName.add("'"+dataCount.getName()+"'"); listData.add(dataCount.getCounts()); } req.setAttribute("listName",listName); req.setAttribute("listData",listData); req.getRequestDispatcher("admin/tongji/index.jsp").forward(req,resp); } catch (Exception throwables) { throwables.printStackTrace(); } break; default: query(req,resp); break; }
}
public void uploadFile(HttpServletRequest req, HttpServletResponse resp) throws Exception { FileItemFactory factory=new DiskFileItemFactory(); ServletFileUpload upload=new ServletFileUpload(factory); List items=upload.parseRequest(req); Iterator it=items.iterator(); String fileName=""; if(it.hasNext()){ FileItem item= (FileItem) it.next(); fileName=item.getName(); String suffName= fileName.substring(fileName.lastIndexOf(".")); fileName= UUID.randomUUID()+suffName; req.setAttribute("fileName",fileName); String basePath="D:\\images"; File f=new File(basePath);
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=461623332808201cu
https://javayms.pages.dev?id=461623332808201cu