zoukankan      html  css  js  c++  java
  • 大作业开发进度1

    今日所做

    • 新增了简单的管理员表

    • 新增了管理员登录的功能

    
    package web;
    
    import dao.UserDao;
    import domain.AdminUser;
    import domain.User;
    
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.IOException;
    import java.sql.SQLException;
    
    @WebServlet("/dengluServlet")
    public class dengluServlet 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 {
            request.setCharacterEncoding("utf-8");
            response.setContentType("text/html;charset=utf-8");
            String rand = (String) request.getSession().getAttribute("rand");
            String username = request.getParameter("user");
            String pwd = request.getParameter("pwd");
            String randcode = request.getParameter("randcode");
            UserDao dao = new UserDao();
            int num_user = 0,num_admin = 0;
            User user = null;
            AdminUser adminUser = null;
            if (!randcode.equals(rand)){
                response.getWriter().write("<script>alert('验证码错误!');window.location.href='"+request.getContextPath()+"/login.html'</script>");
            }
    
    
            //查找是否有账号、以及登录
            try {
                num_user= dao.ajaxUsername(username);
                num_admin = dao.ajaxAdminUser(username);
                user = dao.login(username,pwd);
                adminUser = dao.adminLogin(username,pwd);
            } catch (SQLException e) {
                e.printStackTrace();
                response.getWriter().write("<script>alert('登录失败!');window.location.href='"+request.getContextPath()+"/login.html'</script>");
            }
    
            //登录逻辑处理
    
            if (num_user == 0){
                //用户名不存在,从管理员表中查询
                if (num_admin == 0){
                    //没有该管理员账号
                    response.getWriter().write("<script>alert('该用户不存在,请注册!');window.location.href='"+request.getContextPath()+"/register.html'</script>");
                }else {
                    if (adminUser != null){
                        //管理员登录成功
                        request.getSession().setAttribute("user",adminUser);
                        request.getSession().setAttribute("who","admin");
                        response.getWriter().write("<script>alert('登录成功!');window.location.href='"+request.getContextPath()+"/main.html'</script>");
                    }else if (adminUser == null){
                        //管理员账号或密码错误
                        response.getWriter().write("<script>alert('用户名或密码错误!');window.location.href='"+request.getContextPath()+"/register.html'</script>");
                    }
                }
            }else {
                if (user != null){
                    //账号密码正确
                    request.getSession().setAttribute("user",user);
                    request.getSession().setAttribute("who","user");
                    response.getWriter().write("<script>alert('登录成功!');window.location.href='"+request.getContextPath()+"/main.html'</script>");
                }else if (user == null ){
                    //账号密码错误
                    response.getWriter().write("<script>alert('用户名或密码错误!');window.location.href='"+request.getContextPath()+"/register.html'</script>");
                }
            }
    
    
    
    
        }
    }
    
    
    
    • 新增了用户管理界面

    • 新增了角色管理界面

    • 新增了网络审核界面

    明日计划

    • 完成角色管理功能
    • 完成新增角色功能
    • 完成用户管理功能
  • 相关阅读:
    改变Edit的光标(使用CreateCaret,ShowCaret和LoadBitmap三个API函数)
    浅析Delphi Container库(有开源的DCLX)
    Delphi接口的底层实现(接口在内存中仍然有其布局,它依附在对象的内存空间中,有汇编解释)——接口的内存结构图,简单清楚,深刻 good
    Asp.Net在多线程环境下的状态存储问题
    C#程序中注释过多的8条理由
    CentOS 6.4 编译安装LLVM3.3,Clang和Libc++
    Microsoft 2013校园招聘笔试题及解答
    代码契约CodeContract(八)
    T-SQL 临时表、表变量、UNION
    BST&AVL&红黑树简单介绍
  • 原文地址:https://www.cnblogs.com/wuren-best/p/13843081.html
Copyright © 2011-2022 走看看