——————————DescriptionStart——————————
运行环境 Java≥8、MySQL≥5.7、Tomcat≥8
开发工具 eclipse/idea/myeclipse/sts等均可配置运行
适用 课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的JSP+Servlet医院挂号预约管理系统(java+servlet+jsp+mysql+jdbc)
病人: P001 123456 P002 123456 P003 123456 P004 123456 P005 123456 P006 123456 P007 123456 P008 123456 P009 123456 P010 123456
医生: DR001 123456 DR002 123456 DR003 123456 DR004 123456 DR005 123456 DR006 123456 DR007 123456 DR008 123456 DR009 123456 DR010 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 info = "密码不正确!" ; request.getSession().setAttribute("error" ,info); response.sendRedirect("index.jsp" ); } } else { info = "id不正确!" ; request.getSession().setAttribute("error" ,info); response.sendRedirect("index.jsp" ); } } protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } } @WebServlet(name = "AddReg") public class AddRegServlet extends HttpServlet { private int price=0 ; protected void processRequest (HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException { request.setCharacterEncoding("utf-8" );
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 * **/ @WebFilter(filterName = "LoginFilter") public class LoginFilter implements Filter { private String loginUrl; @Override public void destroy () {} @Override public void doFilter (ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException { HttpServletRequest request=(HttpServletRequest)req; HttpServletResponse response=(HttpServletResponse)resp; HttpSession session = request.getSession(); String uri = ((HttpServletRequest) req).getRequestURI(); if (session.getAttribute("login" ) == null && !loginUrl.contains(uri)) { System.out.println(uri); response.sendRedirect("index.jsp" ); } else { chain.doFilter(req, resp); } } @Override public void init (FilterConfig config) throws ServletException { this .loginUrl = config.getInitParameter("noCheck" ); }
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 /** * used for user to sign out his or her account * **/ @WebServlet(name = "DelUserServlet") public class DelUserServlet extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request,response); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String id=request.getSession().getAttribute("login").toString(); String userType= request.getSession().getAttribute("userType").toString(); if(userType.equals("doctor")) DoctorOperationDAO.deleteData(id); else PatientOperationDAO.deleteData(id); request.getSession().setAttribute("login",null); response.setContentType("text/html;charset=UTF-8"); PrintWriter out=response.getWriter(); out.println("<html > "); out.println("<head > "); out.println(" <title > 注销成功</title > "); out.println("</head > "); out.println("<body > "); out.println(" <script type =\ "text /javascript \"> "); out.println(" alert(\"注销成功\");" ); out.println(" window.location.href=\"index.jsp\";" ); out.println(" </script > "); out.println("</body > "); out.println("</html > "); out.flush(); out.close(); } }
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 response.setCharacterEncoding("utf-8" ); response.setContentType("application/json;charset=utf-8" ); Map<String,Object> map=new HashMap<String,Object>(); String code=request.getParameter("code" ); PrintWriter out=response.getWriter(); if (code==null ||code.length()==0 ) out.print(JSON.toJSONString(ResponseUtil.fail("获取失败。" ))); else { String wxspAppid="wx319e6c738fe40017" ; String wxspSecret="0e4ce40d43d0e77d575f6e970a5db7f8" ; String grant_type="authorization_code" ; String param="appid=" +wxspAppid+"&secret=" +wxspSecret+"&js_code=" +code+"&grant_type=" +grant_type; String sr= HttpUtil.get("https://api.weixin.qq.com/sns/jscode2session" , param); try { JSONObject json=JSONObject.parseObject(sr); System.out.println(json); String session_key=json.get("session_key" ).toString(); String openid=json.get("openid" ).toString(); map.put("openid" ,openid); map.put("session_key" ,session_key); System.out.println(map); out.print(JSON.toJSONString(ResponseUtil.ok(map))); }catch (Exception e){ out.print(JSON.toJSONString(ResponseUtil.fail(sr))); } } } protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException { processRequest(request,response); } protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException { processRequest(request,response); } }
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 /** * used for doctor to accept the registration * **/ @WebServlet(name = "AcceptReg") public class AcceptRegServlet extends HttpServlet { protected void processRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException { request.setCharacterEncoding("utf-8"); String reg_id=request.getParameter("reg_id"); RegOperationDAO.acceptReg(reg_id); response.setContentType("text/html;charset=UTF-8"); PrintWriter out=response.getWriter(); out.println("<html > "); out.println("<head > "); out.println(" <title > 受理成功</title > "); out.println("<head > "); out.println("<body > "); out.println(" <script type =\ "text /javascript \"> "); out.println(" alert(\"受理成功\");" ); out.println(" window.location.href=\"DeptReg\";" ); out.println(" </script > "); out.println("</body > "); out.println("</html > "); out.flush(); out.close(); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request,response); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request,response); } }
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 info = "密码不正确!" ; request.getSession().setAttribute("error" ,info); response.sendRedirect("index.jsp" ); } } else { info = "id不正确!" ; request.getSession().setAttribute("error" ,info); response.sendRedirect("index.jsp" ); } } protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } } @WebServlet(name = "AddReg") public class AddRegServlet extends HttpServlet { private int price=0 ; protected void processRequest (HttpServletRequest request,HttpServletResponse response)
——————————PayStart——————————
项目链接: https://javayms.github.io?id=512024522907201mc https://javayms.pages.dev?id=512024522907201mc