コード例 #1
0
ファイル: ManagerAction.java プロジェクト: cnujia/mini_market
  // 后台添加管理员   上传头像
  public void insert(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    try {
      // 1实例化SmartUpload对象
      SmartUpload su = new SmartUpload();
      // 2 初始化
      su.initialize(this.getServletConfig(), request, response);
      // 3 上传
      su.upload();
      // 4 原名保存所有文件
      su.save("/uploadImage");

      Request req = su.getRequest();
      String name = req.getParameter("name");
      String password = req.getParameter("password");
      String access = req.getParameter("access");
      String pic = req.getParameter("pic");
      int n = pic.lastIndexOf("\\");
      String p = pic.substring(n + 1, pic.length());
      Manager manager = new Manager();
      manager.setName(name);
      manager.setPassword(password);
      manager.setPic(p);
      manager.setAccess(access);
      ManagerDAO.getDAO().insertManager(manager);
      response.sendRedirect("http://localhost:8080/supermarket/manage/jsp/index.jsp");

    } catch (SmartUploadException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
コード例 #2
0
ファイル: ManagerAction.java プロジェクト: cnujia/mini_market
 // 查询黑名单管理员
 public void blackName(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   ArrayList<Manager> managers = ManagerDAO.getDAO().findAllblackName();
   int count = ManagerDAO.count;
   request.setAttribute("count", count);
   request.setAttribute("managers", managers);
   this.getServletContext()
       .getRequestDispatcher("/manage/jsp/blackName.jsp")
       .forward(request, response);
 }
コード例 #3
0
ファイル: ManagerAction.java プロジェクト: cnujia/mini_market
  // 判断管理员是否已被注册
  public void findName(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    String name = request.getParameter("name");

    Boolean isExist = ManagerDAO.getDAO().isExistName(name);
    if (isExist) {
      out.print(1);
    } else {
      out.print(0);
    }
    out.close();
  }
コード例 #4
0
ファイル: ManagerAction.java プロジェクト: cnujia/mini_market
 // 后台修改个人密码
 public void updatePass(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   String oldpass = request.getParameter("oldpass");
   String newpass = request.getParameter("newpass");
   String surepass = request.getParameter("surepass");
   Integer id = Integer.parseInt(request.getParameter("id"));
   Boolean isExist = ManagerDAO.getDAO().isExistPass(oldpass, id);
   if (isExist) {
     if (newpass.equals(surepass)) {
       ManagerDAO.getDAO().updatePass(oldpass, newpass, id);
       response.sendRedirect("http://localhost:8080/supermarket/manage/jsp/login.jsp");
     } else {
       request.setAttribute("err1", "密码不一致");
       this.getServletContext()
           .getRequestDispatcher("/manage/jsp/updatePass.jsp")
           .forward(request, response);
     }
   } else {
     request.setAttribute("err0", "密码错误");
     this.getServletContext()
         .getRequestDispatcher("/manage/jsp/updatePass.jsp")
         .forward(request, response);
   }
 }
コード例 #5
0
ファイル: ManagerAction.java プロジェクト: cnujia/mini_market
 // 后台管理员登录
 public void Login(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   HttpSession session = request.getSession();
   String name = request.getParameter("name");
   String password = request.getParameter("password");
   Manager manage = ManagerDAO.getDAO().login(name, password);
   if (manage != null) {
     int loginCount = ManagerDAO.loginCount;
     session.setAttribute("loginCount", loginCount);
     session.setAttribute("manager", manage);
     //	this.getServletContext().getRequestDispatcher("/manage/jsp/index.jsp").forward(request,
     // response);
     response.sendRedirect("/supermarket/manage/jsp/index.jsp");
     return;
   } else {
     response.sendRedirect("/supermarket/manage/jsp/login.jsp");
   }
 }
コード例 #6
0
ファイル: ManagerAction.java プロジェクト: cnujia/mini_market
 // 恢复管理员
 public void Recover(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   Integer id = Integer.parseInt(request.getParameter("id"));
   ManagerDAO.getDAO().recover(id);
 }