Java项目:校园招聘平台系统(java+MySQL+Jdbc+Servlet+SpringMvc+Jsp)

news/2024/5/18 21:43:03 标签: java, mysql, Servlet, Jsp, jdbc

源码获取:博客首页 "资源" 里下载!

一、项目简述

功能:
用户和企业用户的注册登录,简历的筛选查看搜索,应聘信息互动等等。

二、项目运行

环境配置:

Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

项目技术:

Jdbc+ Servlert + SpringMvc + Jsp + css + JavaScript + JQuery + Ajax + Fileupload等等
 

 

 

 

 

 

登陆控制层:


public class LoginController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        JSONObject jsonObject = new JSONObject();
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        resp.setCharacterEncoding("UTF-8");

        HttpSession session = req.getSession();
        if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
            jsonObject.put("code", 2000);
            jsonObject.put("flag", "fail");
            jsonObject.put("user", null);
            jsonObject.put("msg", "usernameOrPasswordIsBank");//用户名密码不能为空
            resp.getWriter().print(jsonObject);
            return;
        }
        password = MyMD5Util.encrypt(password);
        System.out.println(password);
        BusinessUserVO businessUserVO = new BusinessUserVO();
        businessUserVO.setUsername(username);
        businessUserVO.setPassword(password);
        StudentUserVO studentUserVO = new StudentUserVO();
        studentUserVO.setUsername(username);
        studentUserVO.setPassword(password);

        String flag1 = null;
        String flag2 = null;
        try {
            flag1 = BusinessUserDao.selectUsername(businessUserVO);
            if ("ok".equals(flag1)) {//企业用户名存在
                BusinessUserDTO businessUserDTO = BusinessUserDao.select(businessUserVO);
                if (businessUserDTO != null) {
                    jsonObject.put("code", 2000);
                    jsonObject.put("flag", "success");//登录成功
                    jsonObject.put("user", businessUserDTO);
                    jsonObject.put("msg", "login_success");
                    session.setAttribute("businessUser",businessUserDTO);
                    resp.getWriter().print(jsonObject);
                    return;
                } else {
                    jsonObject.put("code", 2000);
                    jsonObject.put("flag", "fail");//登录失败
                    jsonObject.put("user", null);
                    jsonObject.put("msg", "passwordError");//密码错误
                    resp.getWriter().print(jsonObject);
                    return;
                }
            }
            flag2 = StudentUserDao.selectUsername(studentUserVO);
            if ("ok".equals(flag2)) {//学生用户名存在
                StudentUser studentUser = StudentUserDao.select(studentUserVO);
                if (studentUser != null) {
                    jsonObject.put("code", 2000);
                    jsonObject.put("flag", "success");//登录成功
                    jsonObject.put("user", studentUser);
                    jsonObject.put("msg", "login_success");
                    session.setAttribute("studentUser",studentUser);
                    resp.getWriter().print(jsonObject);
                    return;
                } else {
                    jsonObject.put("code", 2000);
                    jsonObject.put("flag", "fail");//登录失败
                    jsonObject.put("user", null);
                    jsonObject.put("msg", "passwordError");//密码错误
                    resp.getWriter().print(jsonObject);
                    return;
                }

            }
            //用户名不存在,前往注册
            jsonObject.put("code", 2000);
            jsonObject.put("flag", "fail");//登录失败
            jsonObject.put("user", null);
            jsonObject.put("msg", "usernameIsNotExist");//密码错误
            resp.getWriter().print(jsonObject);
            return;

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return;

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        doGet(req, resp);
    }
}

管理员登录控制层:

public class AdminLoginController extends HttpServlet {
    @SneakyThrows
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        password = MyMD5Util.encrypt(password);
        JSONObject jsonObject = new JSONObject();
        HttpSession session = req.getSession();
        Admin admin = new Admin(username, password);
        Admin adminFromDB = AdminDao.findByUsernamePassword(admin);
        if (adminFromDB!=null){
            jsonObject.put("code",2000);
            jsonObject.put("msg","login_success");
            jsonObject.put("admin",adminFromDB.getUsername());
            jsonObject.put("flag","success");
            resp.getWriter().print(jsonObject);
            session.setAttribute("admin",adminFromDB);
            return;
        }else {
            jsonObject.put("code",2000);
            jsonObject.put("msg","no admin");
            jsonObject.put("admin",null);
            jsonObject.put("flag","fail");
            resp.getWriter().print(jsonObject);
            return;
        }

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}

 公司入驻平台控制层:

public class BusinessRegisterController extends HttpServlet {
    @SneakyThrows
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        JSONObject jsonObject = new JSONObject();
        DiskFileItemFactory factory = new DiskFileItemFactory();
        ServletFileUpload upload = new ServletFileUpload(factory);
        req.setCharacterEncoding("UTF-8");
        upload.setHeaderEncoding("UTF-8");
        List<FileItem> items = upload.parseRequest(req);
        StringBuffer sb = new StringBuffer();
        String companyFile = null;
        for (FileItem item : items) {
            String name = item.getFieldName();
            InputStream inputStream = item.getInputStream();
            if (!name.equals("companyFile")){
                String string = item.getString();
                string = new String(string.getBytes("ISO8859_1"), StandardCharsets.UTF_8);
                sb.append(string+"&&");

            }else {
                String[] split = sb.toString().split("&&");
                String companyName = split[0];
                String companyId = split[1];
                String path=req.getServletContext().getRealPath("/");
                System.out.println(path);
                String fieldName = companyName+"_"+companyId+"_"+item.getName();
                String filePath = path+fieldName;
                companyFile = fieldName;
                File file = new File(filePath);
                BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
                FileOutputStream fileOutputStream = new FileOutputStream(file);
                int line;
                while ((line = bufferedInputStream.read())!=-1){
                    fileOutputStream.write(line);
                }
                fileOutputStream.flush();
                fileOutputStream.close();
                bufferedInputStream.close();
            }
        }
        String[] split = sb.toString().split("&&");
        String companyName = split[0];
        String companyId = split[1];
        String password = split[2];
        String password2 = MyMD5Util.encrypt(password);
        BusinessVO businessVO = new BusinessVO(companyName, companyId, password2, companyFile);

        try {
            int i = BusinessDao.insertToVerify(businessVO);
            if (i == 1){
                jsonObject.put("code",2000);
                jsonObject.put("msg","waiting verify");//企业用户注册完,等待管理员审核
                resp.getWriter().print(jsonObject);
                return;
            }else {
                jsonObject.put("code",2000);
                jsonObject.put("msg","companyId exist");//企业id已存在
                resp.getWriter().print(jsonObject);
                return;
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
            jsonObject.put("code",5000);
            jsonObject.put("msg","server error");
            resp.getWriter().print(jsonObject);
            return;
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}

源码获取:博客首页 "资源" 里下载!


http://www.niftyadmin.cn/n/1554352.html

相关文章

stb微型计算机什么语句,微机原理及接口技术课外习题及答案

IP和段寄存器依次属于____BIU、BIU1. 设M/IO、RD和WR在某时刻分别为1、1和0&#xff0c;指令中与其对应的是___ MOV ES:[DI], AX 2. 执行返回指令&#xff0c;退出中断服务程序&#xff0c;这时返回地址来自_____。堆栈区 5 从硬件角度而言&#xff0c;采用硬件最少的数据传送方…

Java项目:家庭理财系统(java+SSM+JSP+Tomcat8+Mysql)

源码获取&#xff1a;博客首页 "资源" 里下载&#xff01; 一、项目简述 功能&#xff1a;家庭理财&#xff0c;财务分析&#xff0c;统计等等。 二、项目运行 运行环境: jdk8tomcat8mysqlIntelliJ IDEA&#xff08; Eclispe , MyEclispe ,Sts 都支持&#xff0c;代…

allure 测试报告本地打开_2019款蔚来ES6日常实用性测试报告

2017年蔚来汽车首款SUV车型ES8正式上市&#xff0c;从上市至今&#xff0c;围绕它身上的话题似乎从来没有停止过&#xff0c;而这也侧面说明了它从诞生至今就有着自己独特之处&#xff0c;但是其高昂的售价却让一些想购买它的消费者只能望而却步。如今&#xff0c; ES6的推出似…

计算机网局域网概念,计算机局域网知识点:局域网的概念

计算机局域网知识点&#xff1a;局域网的概念 (2页)本资源提供全文预览&#xff0c;点击全文预览即可全文预览,如果喜欢文档就下载吧&#xff0c;查找使用更方便哦&#xff01;11.90 积分&#xfeff;2006年6月9日一、局域网的概念   1、局域网的概念   指在一个较小地理范…

Java项目:农业计算工具(java+swing)

1、换算:吨、千克、斤&#xff0c;晌/公顷、亩、平方米&#xff0c;晌/株、亩/株、平方米/株 2、籽粒干重、果穗干重、出籽率计算 3、发芽种粒数、供试种粒数、发芽率计算 4、种子袋、晌、亩、品种 换算 package com.euyy;public class BigCount {public String BigCountTool(S…

可涂抹什么让指纹加深_#知识问答#为什么有的透明胶带是淡黄色的?

BOPP薄膜本身就是透明的&#xff0c;而普通透明胶带呈现淡黄色&#xff0c;是因为它所使用的胶——压敏胶&#xff0c;通常以橙色、米黄色为主&#xff0c;如果涂抹少量的话&#xff0c;没有什么变化&#xff0c;但是量多的话&#xff0c;颜色会加深&#xff0c;特别是将BOPP胶…

Java项目:抽奖点名神器(HTML+可自定义抽选)

用于年终抽奖或随机点名神器 //获取页面元素var student_box document.getElementById("student_box");//循环生成HTMLvar html "";for (var i 0 ; i < 22; i ) {html <div style"width:120px; height:120px;"><img src"./p…

超级计算机的进化过程,科学家借软件模拟最详细的宇宙进化过程

一个国际研究团队在实验室完成了宇宙进化的模拟。这个计算机模型展示了神秘无形的暗物质团如何形成第一批星系。这也是科学家们第一次以如此广泛和如此高的分辨率来模拟宇宙。这次模拟将为宇宙组成和如何运转的新兴理论提供一个测试平台。全世界星系构成研究领域最权威的专家&a…