基于javaweb+mysql的jsp+servlet场馆场地预约管理系统(java+jsp+servlet+mysql+tomcat)

基于javaweb+mysql的jsp+servlet场馆场地预约管理系统(java+jsp+servlet+mysql+tomcat)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

前台可以自由注册,后台只有管理员可以进去。

前台功能:首页、场馆介绍、场馆预约、场馆通知、个人中心。

后台功能:场馆管理、用户管理、预约审核、通知管理、场地管理、场地安排管理。

前台

后台

技术框架

JSP Servlet MySQL Tomcat JavaScript CSS jstl jQuery Bootstrap

基于javaweb+mysql的JSP+Servlet场馆场地预约管理系统(java+jsp+servlet+mysql+tomcat)


        Place place = new Place();
        String name = params.get("name");
        String ename = params.get("ename");
        String location = params.get("location");
        String introduction = params.get("introduction");
        place.setId(Integer.parseInt(params.get("id")));
        place.setName(name);
        place.setEname(ename);
        place.setLocation(location);
        place.setIntroduction(introduction);
        placeDAO.update(place);
            File imageFolder = new File(request.getSession().getServletContext().getRealPath("image/place"));
        if(!imageFolder.exists()){
            imageFolder.mkdirs();
        }
            File file = new File(imageFolder, place.getId() + ".jpg");
            try {
                if (is != null && is.available() != 0) {
                    try(FileOutputStream fos = new FileOutputStream(file)) {
                        byte b[] = new byte[1024 * 1024];
                        int length = 0;
                        while ((length = is.read(b)) != -1) {
                            fos.write(b, 0, length);
                        }
                        fos.flush();
                        BufferedImage img = ImageUtil.change2jpg(file);
                        ImageIO.write(img, "jpg", file);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

        return "@admin_place_list";
    }

    public String list(HttpServletRequest request, HttpServletResponse response, Page page) {
        List<Place> places = placeDAO.list(page.getStart(), page.getCount());
        int total = placeDAO.getTotal();
        page.setTotal(total);

            return "%fail";
        }
        request.getSession().setAttribute("user", user);
        return "%success";
    }

    //预定页
    public String book(HttpServletRequest request, HttpServletResponse response, Page page) {

        //所有场馆
        List<Place> placeList = new PlaceDAO().list();
        request.setAttribute("placeList", placeList);

        //可选日期信息
        Date current = new Date(System.currentTimeMillis());
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(current);
        List<java.sql.Date> dateValid = new ArrayList<>();
        calendar.add(Calendar.DATE, 0);
        dateValid.add(new java.sql.Date(calendar.getTimeInMillis()));
        calendar.add(Calendar.DATE, 1);
        dateValid.add(new java.sql.Date(calendar.getTimeInMillis()));
        calendar.add(Calendar.DATE, 1);
        dateValid.add(new java.sql.Date(calendar.getTimeInMillis()));
        request.setAttribute("dates", dateValid);

        //当前所选场馆、场地、安排表
        String pid = request.getParameter("pid");
        String psid = request.getParameter("psid");

        Place place = null;     //场馆:需要填充场地
        PlaceStadium placeStadium = null;       //场地:需要填充安排表
        String date = null;   //日期:切换场馆或场地设的日期

        //获得场馆
        if (pid == null) {  //未选择场馆
            place = placeList.get(0);
        } else {
            place = placeDAO.get(Integer.parseInt(pid));

public abstract class BaseBackServlet extends HttpServlet {

    public abstract String add(HttpServletRequest request, HttpServletResponse response, Page page) ;
    public abstract String delete(HttpServletRequest request, HttpServletResponse response, Page page) ;
    public abstract String edit(HttpServletRequest request, HttpServletResponse response, Page page) ;
    public abstract String update(HttpServletRequest request, HttpServletResponse response, Page page) throws UnsupportedEncodingException;
    public abstract String list(HttpServletRequest request, HttpServletResponse response, Page page) throws IOException;

    //用户方面
    protected UserDAO userDAO = new UserDAO();
    //订单方面
    protected ReserveDAO reserveDAO = new ReserveDAO();
    protected ReserveItemDAO reserveItemDAO = new ReserveItemDAO();
    //场地方面
    protected PlaceDAO placeDAO = new PlaceDAO();
    protected PlaceStadiumDAO placeStadiumDAO = new PlaceStadiumDAO();
    protected PlaceImageDAO placeImageDAO = new PlaceImageDAO();
    protected StadiumPlanDAO stadiumPlanDAO = new StadiumPlanDAO();
    protected StadiumPlanItemDAO stadiumPlanItemDAO = new StadiumPlanItemDAO();
    //通知方面
    protected NewsDAO newsDAO = new NewsDAO();

    public void service(HttpServletRequest request, HttpServletResponse response) {
        try {
            /*获取分页信息*/
            int start= 0;
            int count = 5;
            try {
                start = Integer.parseInt(request.getParameter("page.start"));
            } catch (Exception e) {

            }
            try {
                count = Integer.parseInt(request.getParameter("page.count"));
            } catch (Exception e) {
            }
            Page page = new Page(start,count);

            /*借助反射,调用对应的方法*/
            String method = (String) request.getAttribute("method");
            Method m = this.getClass().getMethod(method, javax.servlet.http.HttpServletRequest.class,
                    javax.servlet.http.HttpServletResponse.class,Page.class);
            String redirect = m.invoke(this,request, response,page).toString();

            /*根据方法的返回值,进行相应的客户端跳转,服务端跳转,或者仅仅是输出字符串*/

            if(redirect.startsWith("@"))
                response.sendRedirect(redirect.substring(1));   //页面重定向
            else if(redirect.startsWith("%"))
    }

    /*提交后:安排项修改为:未付款,订单修改为未付款*/
    //审核通过:安排表项修改为:,订单修改为占用
    public String pass(HttpServletRequest request, HttpServletResponse response, Page page) {
        int rid = Integer.parseInt(request.getParameter("rid"));
        reserveDAO.edit(rid, "审核通过");
        Reserve reserve = new Reserve();
        reserve.setId(rid);
        reserveItemDAO.fill(reserve);
        for (int i = 0; i < reserve.getReserveItemList().size(); i++) {
            stadiumPlanItemDAO.edit(reserve.getReserveItemList().get(i).getStadiumPlanItem().getId(), "已预约");
        }
        return "@admin_reserve_list";
    }

    //审核失败:安排表项修改为:空闲,订单修改为审核未通过
    public String fail(HttpServletRequest request, HttpServletResponse response, Page page) {
        int rid = Integer.parseInt(request.getParameter("rid"));
        reserveDAO.edit(rid, "审核未通过");
        Reserve reserve = new Reserve();
        reserve.setId(rid);
        reserveItemDAO.fill(reserve);
        for (int i = 0; i < reserve.getReserveItemList().size(); i++) {
            stadiumPlanItemDAO.edit(reserve.getReserveItemList().get(i).getStadiumPlanItem().getId(), "空闲");
        }
        return "@admin_reserve_list";
    }

}

@WebServlet(name = "BaseForeServlet")
public class BaseForeServlet extends HttpServlet {
    //日期格式
    protected final static String A="yyyy-MM-dd";
    protected final static String B="yyyy-MM-dd HH:mm:ss";
    protected final static String C="yyyy/MM/dd HH:mm:ss";

public class BackServletFilter implements Filter {

    public void destroy() {

    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
            throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) res;

        String contextPath=request.getServletContext().getContextPath();
        String uri = request.getRequestURI();
        uri =StringUtils.remove(uri, contextPath);

        if(uri.startsWith("/admin_")){
            String servletPath = StringUtils.substringBetween(uri,"_", "_") + "Servlet";
            String method = StringUtils.substringAfterLast(uri,"_" );
            request.setAttribute("method", method);
            req.getRequestDispatcher("/" + servletPath).forward(request, response);
            return;
        }

        chain.doFilter(request, response);
    }

    public void init(FilterConfig arg0) throws ServletException {

    }
}

    public abstract String delete(HttpServletRequest request, HttpServletResponse response, Page page) ;
    public abstract String edit(HttpServletRequest request, HttpServletResponse response, Page page) ;
    public abstract String update(HttpServletRequest request, HttpServletResponse response, Page page) throws UnsupportedEncodingException;
    public abstract String list(HttpServletRequest request, HttpServletResponse response, Page page) throws IOException;

    //用户方面
    protected UserDAO userDAO = new UserDAO();
    //订单方面
    protected ReserveDAO reserveDAO = new ReserveDAO();
    protected ReserveItemDAO reserveItemDAO = new ReserveItemDAO();
    //场地方面
    protected PlaceDAO placeDAO = new PlaceDAO();
    protected PlaceStadiumDAO placeStadiumDAO = new PlaceStadiumDAO();
    protected PlaceImageDAO placeImageDAO = new PlaceImageDAO();
    protected StadiumPlanDAO stadiumPlanDAO = new StadiumPlanDAO();
    protected StadiumPlanItemDAO stadiumPlanItemDAO = new StadiumPlanItemDAO();
    //通知方面
    protected NewsDAO newsDAO = new NewsDAO();

    public void service(HttpServletRequest request, HttpServletResponse response) {
        try {
            /*获取分页信息*/
            int start= 0;
            int count = 5;
            try {
                start = Integer.parseInt(request.getParameter("page.start"));
            } catch (Exception e) {

            }
            try {
                count = Integer.parseInt(request.getParameter("page.count"));
            } catch (Exception e) {
            }
            Page page = new Page(start,count);

            /*借助反射,调用对应的方法*/
            String method = (String) request.getAttribute("method");
            Method m = this.getClass().getMethod(method, javax.servlet.http.HttpServletRequest.class,
                    javax.servlet.http.HttpServletResponse.class,Page.class);
            String redirect = m.invoke(this,request, response,page).toString();

            /*根据方法的返回值,进行相应的客户端跳转,服务端跳转,或者仅仅是输出字符串*/

            if(redirect.startsWith("@"))
                    // item.getInputStream() 获取上传文件的输入流
                    is = item.getInputStream();
                } else {
                    String paramName = item.getFieldName();
                    String paramValue = item.getString();
                    paramValue = new String(paramValue.getBytes("ISO-8859-1"), "UTF-8");
                    params.put(paramName, paramValue);
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return is;
    }
}

public class PlaceServlet extends BaseBackServlet {

    public String add(HttpServletRequest request, HttpServletResponse response, Page page) {
        Map<String, String> params = new HashMap<>();
        InputStream is = super.parseUpload(request, params);

        Place place = new Place();

        place.setName(params.get("name"));
        place.setEname(params.get("ename"));
        place.setLocation(params.get("location"));
        place.setIntroduction(params.get("introduction"));
        placeDAO.add(place);

        File imageFolder = new File(request.getSession().getServletContext().getRealPath("image/place"));
        if(!imageFolder.exists()){
            imageFolder.mkdirs();
        }
        placeStadiumDAO.fill(place);  //填充场馆的场地
        request.setAttribute("place", place);

        //获得场地
        if (psid == null) {   //未选择场地
            placeStadium = place.getPlaceStadium().get(0);
        } else {    //选过场地,移除默认场馆
            placeStadium = placeStadiumDAO.get(Integer.parseInt(psid));
            placeStadiumDAO.fill(placeStadium.getPlace());
            request.removeAttribute("place");
            request.setAttribute("place", placeStadium.getPlace());
        }
        request.setAttribute("placeStadium", placeStadium);
        request.setAttribute("name", placeStadium.getName());

        List<List<StadiumPlan>> lists = new ArrayList<>();
        //每个日期获得一个安排表列表
        for (int i = 0; i < dateValid.size(); i++)
            lists.add(stadiumPlanDAO.search(placeStadium.getId(), dateValid.get(i)));
        request.setAttribute("lists", lists);

        if (date == null) {
            date = dateValid.get(0).toString();
        }
        request.setAttribute("date", date);
        request.setAttribute("where", "book.jsp");

        if (request.getParameter("flag") != null)
            request.setAttribute("flag", 1);

        return "book.jsp";
    }
    //订单生成:安排项修改为:未付款,订单修改为未付款
    public String bookSubmit(HttpServletRequest request, HttpServletResponse response, Page page) {
        /*生成新订单*/
        Reserve reserve = new Reserve();

        /*订单提交的处理*/
        User user =(User) request.getSession().getAttribute("user");    //用户
        int pid = Integer.parseInt(request.getParameter("pid"));     //场馆
        int psid = Integer.parseInt(request.getParameter("psid"));   //场地
        int fare = Integer.parseInt(request.getParameter("fare"));      //总价格

        //新增订单
        reserve.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
        reserve.setName(placeDAO.get(pid).getName()+placeStadiumDAO.get(psid).getName());
        reserve.setFare(fare);
        reserve.setStatus("未付款");
        reserve.setUser(user);

        reserveDAO.add(reserve);

public class PlaceServlet extends BaseBackServlet {

    public String add(HttpServletRequest request, HttpServletResponse response, Page page) {
        Map<String, String> params = new HashMap<>();
        InputStream is = super.parseUpload(request, params);

        Place place = new Place();

        place.setName(params.get("name"));
        place.setEname(params.get("ename"));
        place.setLocation(params.get("location"));
        place.setIntroduction(params.get("introduction"));
        placeDAO.add(place);

        File imageFolder = new File(request.getSession().getServletContext().getRealPath("image/place"));
        if(!imageFolder.exists()){
            imageFolder.mkdirs();
        }
        //System.out.println(request.getSession().getServletContext().getRealPath("image/place"));
        File file = new File(imageFolder, place.getId() + ".jpg");

        try {
            if (is != null && is.available() != 0) {
                try(FileOutputStream fos = new FileOutputStream(file)) {
                    byte b[] = new byte[1024 * 1024];
                    int length = 0;
                    while ((length = is.read(b)) != -1) {
                        fos.write(b, 0, length);
                    }
                    fos.flush();
                    BufferedImage img = ImageUtil.change2jpg(file);
                    ImageIO.write(img, "jpg", file);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                reserveItemDAO.add(reserveItem);
            }
        }

        return "@forebook?flag=1";
    }

    //用户页及操作
    public String user(HttpServletRequest request, HttpServletResponse response, Page page) {
        User user = (User)request.getSession().getAttribute("user");
        List<Reserve> reserveList = reserveDAO.list(user.getId());
        for (int i = 0; i < reserveList.size(); i++) {
            reserveItemDAO.fill(reserveList.get(i));
        }
        request.setAttribute("reserveList", reserveList);
        return "user.jsp";
    }

    public String useredit(HttpServletRequest request, HttpServletResponse response, Page page) {
        User user = (User)request.getSession().getAttribute("user");
        user.setEmail(request.getParameter("email"));
        userDAO.update(user);
        return user(request, response, page);
    }
    //付款及修改状态
    public String userPay(HttpServletRequest request, HttpServletResponse response, Page page) {
        int rid = Integer.parseInt(request.getParameter("rid"));
        Reserve reserve = new Reserve();
        reserve.setId(rid);
        //订单状态修改为已支付
        reserveDAO.edit(rid, "审核中");
        //场地安排表项状态修改为"审核中"
        reserveItemDAO.fill(reserve);
        for (int i = 0; i < reserve.getReserveItemList().size(); i++) {
            stadiumPlanItemDAO.edit(reserve.getReserveItemList().get(i).getId(), "审核中");
        }
        return "@foreuser";
    }

    public String deleteReserve(HttpServletRequest request, HttpServletResponse response, Page page) {
        reserveDAO.delete(Integer.parseInt(request.getParameter("rid")));
        return "@admin_place_list";
    }

    public String edit(HttpServletRequest request, HttpServletResponse response, Page page) {
        return "";
    }

    public String update(HttpServletRequest request, HttpServletResponse response, Page page) throws UnsupportedEncodingException {
        Map<String, String> params = new HashMap<>();
        InputStream is = super.parseUpload(request, params);

        Place place = new Place();
        String name = params.get("name");
        String ename = params.get("ename");
        String location = params.get("location");
        String introduction = params.get("introduction");
        place.setId(Integer.parseInt(params.get("id")));
        place.setName(name);
        place.setEname(ename);
        place.setLocation(location);
        place.setIntroduction(introduction);
        placeDAO.update(place);
            File imageFolder = new File(request.getSession().getServletContext().getRealPath("image/place"));
        if(!imageFolder.exists()){
            imageFolder.mkdirs();
        }
            File file = new File(imageFolder, place.getId() + ".jpg");
            try {
                if (is != null && is.available() != 0) {
                    try(FileOutputStream fos = new FileOutputStream(file)) {
                        byte b[] = new byte[1024 * 1024];
                        int length = 0;
                        while ((length = is.read(b)) != -1) {
                            fos.write(b, 0, length);
                        }
                        fos.flush();
                        BufferedImage img = ImageUtil.change2jpg(file);
                        ImageIO.write(img, "jpg", file);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            } catch (Exception e) {

@WebServlet(name = "ForeServlet")
public class ForeServlet extends  BaseForeServlet{
    //主页
    public String home(HttpServletRequest request, HttpServletResponse response, Page page) {
        //场馆
        List<Place> placeList = placeDAO.list(0, 5);
        request.setAttribute("places", placeList);
        //通知
        List<News> newsList = newsDAO.list(0, 5);
        request.setAttribute("news", newsList);
        request.setAttribute("where", "home.jsp");
        return "home.jsp";
    }
    //场馆介绍页
    public String introduce(HttpServletRequest request, HttpServletResponse response, Page page) {
        request.setAttribute("where", "introduce.jsp");

        List<Place> placeList = placeDAO.list();
        request.setAttribute("placeList", placeList);

        return "introduce.jsp";
    }

    //注册
    public String register(HttpServletRequest request, HttpServletResponse response, Page page) {
        try {
            String name = new String(request.getParameter("name").getBytes("ISO-8859-1"),"UTF-8");
            String password = request.getParameter("password");
            String email = request.getParameter("email");
            name = HtmlUtils.htmlEscape(name);
            boolean exist = userDAO.isExist(name);

            if (exist) {
                request.setAttribute("msg", "*用户名已经被使用!");
                return "register.jsp";
            }
            User user = new User();
            user.setName(name);
            user.setPassword(password);
            user.setEmail(email);
            userDAO.add(user);
        } catch (IOException e) {
            e.printStackTrace();
            }
        }

        return "@forebook?flag=1";
    }

    //用户页及操作
    public String user(HttpServletRequest request, HttpServletResponse response, Page page) {
        User user = (User)request.getSession().getAttribute("user");
        List<Reserve> reserveList = reserveDAO.list(user.getId());
        for (int i = 0; i < reserveList.size(); i++) {
            reserveItemDAO.fill(reserveList.get(i));
        }
        request.setAttribute("reserveList", reserveList);
        return "user.jsp";
    }

    public String useredit(HttpServletRequest request, HttpServletResponse response, Page page) {
        User user = (User)request.getSession().getAttribute("user");
        user.setEmail(request.getParameter("email"));
        userDAO.update(user);
        return user(request, response, page);
    }
    //付款及修改状态
    public String userPay(HttpServletRequest request, HttpServletResponse response, Page page) {
        int rid = Integer.parseInt(request.getParameter("rid"));
        Reserve reserve = new Reserve();
        reserve.setId(rid);
        //订单状态修改为已支付
        reserveDAO.edit(rid, "审核中");
        //场地安排表项状态修改为"审核中"
        reserveItemDAO.fill(reserve);
        for (int i = 0; i < reserve.getReserveItemList().size(); i++) {
            stadiumPlanItemDAO.edit(reserve.getReserveItemList().get(i).getId(), "审核中");
        }
        return "@foreuser";
    }

    public String deleteReserve(HttpServletRequest request, HttpServletResponse response, Page page) {
        reserveDAO.delete(Integer.parseInt(request.getParameter("rid")));
        return "@foreuser";
    }

    //通知页
    public String news(HttpServletRequest request, HttpServletResponse response, Page page) {
        request.setAttribute("where", "news.jsp");

        List<News> newsList = newsDAO.list();
        request.setAttribute("newsList", newsList);
        return "news.jsp";
    }

    public String newsShow(HttpServletRequest request, HttpServletResponse response, Page page) {

public abstract class BaseBackServlet extends HttpServlet {

    public abstract String add(HttpServletRequest request, HttpServletResponse response, Page page) ;
    public abstract String delete(HttpServletRequest request, HttpServletResponse response, Page page) ;
    public abstract String edit(HttpServletRequest request, HttpServletResponse response, Page page) ;
    public abstract String update(HttpServletRequest request, HttpServletResponse response, Page page) throws UnsupportedEncodingException;
    public abstract String list(HttpServletRequest request, HttpServletResponse response, Page page) throws IOException;

    //用户方面
    protected UserDAO userDAO = new UserDAO();
    //订单方面
    protected ReserveDAO reserveDAO = new ReserveDAO();
    protected ReserveItemDAO reserveItemDAO = new ReserveItemDAO();
    //场地方面
    protected PlaceDAO placeDAO = new PlaceDAO();
    protected PlaceStadiumDAO placeStadiumDAO = new PlaceStadiumDAO();
    protected PlaceImageDAO placeImageDAO = new PlaceImageDAO();
    protected StadiumPlanDAO stadiumPlanDAO = new StadiumPlanDAO();
    protected StadiumPlanItemDAO stadiumPlanItemDAO = new StadiumPlanItemDAO();
    //通知方面
    protected NewsDAO newsDAO = new NewsDAO();

    public void service(HttpServletRequest request, HttpServletResponse response) {
        try {
            /*获取分页信息*/
            int start= 0;
            int count = 5;
            try {
                start = Integer.parseInt(request.getParameter("page.start"));
    protected final static String A="yyyy-MM-dd";
    protected final static String B="yyyy-MM-dd HH:mm:ss";
    protected final static String C="yyyy/MM/dd HH:mm:ss";

    //数据处理实体类
    protected UserDAO userDAO = new UserDAO();
    protected PlaceDAO placeDAO = new PlaceDAO();
    protected PlaceStadiumDAO placeStadiumDAO = new PlaceStadiumDAO();
    protected StadiumPlanDAO stadiumPlanDAO = new StadiumPlanDAO();
    protected StadiumPlanItemDAO stadiumPlanItemDAO = new StadiumPlanItemDAO();
    protected ReserveDAO reserveDAO = new ReserveDAO();
    protected NewsDAO newsDAO = new NewsDAO();
    protected ReserveItemDAO reserveItemDAO = new ReserveItemDAO();

    public void service(HttpServletRequest request, HttpServletResponse response) {
        try {

            int start= 0;
            int count = 10;
            try {
                start = Integer.parseInt(request.getParameter("page.start"));
            } catch (Exception e) {

            }

            try {
                count = Integer.parseInt(request.getParameter("page.count"));
            } catch (Exception e) {
            }

            Page page = new Page(start,count);

            String method = (String) request.getAttribute("method");

            Method m = this.getClass().getMethod(method, javax.servlet.http.HttpServletRequest.class,
                    javax.servlet.http.HttpServletResponse.class,Page.class);

            String redirect = m.invoke(this,request, response,page).toString();

            if(redirect.startsWith("@"))    //页面跳转,浏览器中地址改变
                response.sendRedirect(redirect.substring(1));
            else if(redirect.startsWith("%"))
                response.getWriter().print(redirect.substring(1));
            else    //浏览器中地址不变
                request.getRequestDispatcher(redirect).forward(request, response);

        } catch (Exception e) {
            e.printStackTrace();

        List<Place> placeList = placeDAO.list();
        request.setAttribute("placeList", placeList);

        return "introduce.jsp";
    }

    //注册
    public String register(HttpServletRequest request, HttpServletResponse response, Page page) {
        try {
            String name = new String(request.getParameter("name").getBytes("ISO-8859-1"),"UTF-8");
            String password = request.getParameter("password");
            String email = request.getParameter("email");
            name = HtmlUtils.htmlEscape(name);
            boolean exist = userDAO.isExist(name);

            if (exist) {
                request.setAttribute("msg", "*用户名已经被使用!");
                return "register.jsp";
            }
            User user = new User();
            user.setName(name);
            user.setPassword(password);
            user.setEmail(email);
            userDAO.add(user);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return login(request, response, page);
    }

    //登陆、登出
    public String login(HttpServletRequest request, HttpServletResponse response, Page page) {
        try {
            String name = new String(request.getParameter("name").getBytes("ISO-8859-1"),"UTF-8");
            name = HtmlUtils.htmlEscape(name);
            String password = request.getParameter("password");

            User user = userDAO.get(name, password);

            if (user == null) {

        //获取能获取的有效日期
        Date current = new Date(System.currentTimeMillis());
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(current);
        List<java.sql.Date> dateValid = new ArrayList<>();
        calendar.add(Calendar.DATE, 0);
        dateValid.add(new java.sql.Date(calendar.getTimeInMillis()));
        calendar.add(Calendar.DATE, 1);
        dateValid.add(new java.sql.Date(calendar.getTimeInMillis()));
        calendar.add(Calendar.DATE, 1);
        dateValid.add(new java.sql.Date(calendar.getTimeInMillis()));

        //获取所有场的安排表

        List<StadiumPlan> stadiumPlanList = stadiumPlanDAO.search(psid, date);
        request.setAttribute("place", place);
        request.setAttribute("placeStadiums", placeStadiums);
        request.setAttribute("stadiumPlanList", stadiumPlanList);
        request.setAttribute("dates", dateValid);
        request.setAttribute("date", date);
        request.setAttribute("name", placeStadium.getName());

        return "admin/listStadiumPlan.jsp";
    }

}

public class PlaceStadiumServlet extends BaseBackServlet{
    public String add(HttpServletRequest request, HttpServletResponse response, Page page) {
        Map<String, String> params = new HashMap<>();
        InputStream is = super.parseUpload(request, params);

        PlaceStadium placeStadium = new PlaceStadium();
        placeStadium.setName(params.get("name"));

请添加图片描述

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值