欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Java實戰(zhàn)之兼職平臺系統(tǒng)的實現(xiàn)

 更新時間:2022年03月16日 15:43:23   作者:qq_1334611189  
這篇文章主要介紹了如何利用Java編寫一個兼職平臺系統(tǒng),采用到的技術有Springboot、SpringMVC、MyBatis、ThymeLeaf等,感興趣的小伙伴可以了解一下

一、項目運行

環(huán)境配置:

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

項目技術:

HTML +Springboot+ SpringMVC + MyBatis + ThymeLeaf + JavaScript + JQuery + Ajax + maven等等.

二、效果圖

三、核心代碼

登錄控制層

 
 
/**
 * @Author yy
 * @Description 登錄
 * @Date 2022.2.17
 */
 
 
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)) {//企業(yè)用戶名存在
                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 SubmitResumeController 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 resumeFile = null;
        for (FileItem item : items) {
            String name = item.getFieldName();
            InputStream inputStream = item.getInputStream();
            if (!name.equals("resumeFile")){
                String string = item.getString();
                string = new String(string.getBytes("ISO8859_1"), StandardCharsets.UTF_8);
                sb.append(string+"&&");
            }else {
                String[] split = sb.toString().split("&&");
                String studentName = split[0];
                String studentUsername = split[1];
                String recruitInfoId = split[2];
                String path=req.getServletContext().getRealPath("/");
                String fieldName = studentName+"_"+studentUsername+"_"+recruitInfoId+"_"+item.getName();
                String filePath = path+fieldName;
                resumeFile = 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 studentName = split[0];
        String studentUsername = split[1];
        String recruitInfoId = split[2];
        String applyPosition = split[3];
        String phoneNum = split[4];
        String email = split[5];
        Resume resume = new Resume(studentUsername, Integer.parseInt(recruitInfoId), studentName, applyPosition, phoneNum, email, resumeFile);
        int insert = ResumeDao.insert(resume);
        if (insert == 1){
            jsonObject.put("code",2000);
            jsonObject.put("msg","add success");
            jsonObject.put("flag","success");
            jsonObject.put("data",resume);
            resp.getWriter().print(jsonObject);
            return;
        }else {
            jsonObject.put("code",2000);
            jsonObject.put("msg","add fail");
            jsonObject.put("flag","fail");
            jsonObject.put("data",null);
            resp.getWriter().print(jsonObject);
        }
 
 
    }
 
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}

到此這篇關于Java實戰(zhàn)之兼職平臺系統(tǒng)的實現(xiàn)的文章就介紹到這了,更多相關Java兼職平臺系統(tǒng)內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • java基礎之方法詳解

    java基礎之方法詳解

    這篇文章主要介紹了java基礎之方法詳解,文中有非常詳細的代碼示例,對正在學習java基礎的小伙伴們有非常好的幫助,需要的朋友可以參考下
    2021-07-07
  • java構建Stream流的多種方式總結

    java構建Stream流的多種方式總結

    Java?8引入了Stream流作為一項新的特性,它是用來處理集合數(shù)據(jù)的一種函數(shù)式編程方式,本文為大家整理了多種java構建Stream流的方式,希望對大家有所幫助
    2023-11-11
  • Java中List集合去除重復數(shù)據(jù)的方法匯總

    Java中List集合去除重復數(shù)據(jù)的方法匯總

    這篇文章主要給大家介紹了關于Java中List集合去除重復數(shù)據(jù)的方法,文中通過圖文介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2021-02-02
  • IntelliJ IDEA下SpringBoot如何指定某一個配置文件啟動項目

    IntelliJ IDEA下SpringBoot如何指定某一個配置文件啟動項目

    這篇文章主要介紹了IntelliJ IDEA下SpringBoot如何指定某一個配置文件啟動項目問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-09-09
  • Java編程實現(xiàn)多線程TCP服務器完整實例

    Java編程實現(xiàn)多線程TCP服務器完整實例

    這篇文章主要介紹了Java編程實現(xiàn)多線程TCP服務器完整實例,具有一定借鑒價值,需要的朋友可以參考下
    2018-01-01
  • Java Flink窗口觸發(fā)器Trigger的用法詳解

    Java Flink窗口觸發(fā)器Trigger的用法詳解

    Trigger(窗口觸發(fā)器)決定了窗口(由 WindowAssigner 產(chǎn)生)什么時候調用窗口處理函數(shù)??梢愿鶕?jù)指定的時間或數(shù)據(jù)元素條件來決定什么時候觸發(fā)。本文將詳細講講其用法,需要的可以參考一下
    2022-07-07
  • java分布式面試降級組件Hystrix的功能特性

    java分布式面試降級組件Hystrix的功能特性

    這篇文章主要為大家介紹了java分布式面試關于降級組件Hystrix的功能特性回答,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步
    2022-03-03
  • springboot整合httpClient代碼實例

    springboot整合httpClient代碼實例

    這篇文章主要介紹了springboot整合httpClient代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2019-12-12
  • Java中的CompletableFuture異步編程詳解

    Java中的CompletableFuture異步編程詳解

    這篇文章主要介紹了Java中的CompletableFuture異步編程詳解,只要提到多線程來優(yōu)化性能,那么必定離不開異步化,異步化的出現(xiàn)才是多線程優(yōu)化性能這個核心方案的基礎,需要的朋友可以參考下
    2023-12-12
  • Java 深入淺出掌握Collection單列集合Set

    Java 深入淺出掌握Collection單列集合Set

    Collection集合類是單列集合類的根接口,用來存儲一系列符合某種規(guī)則的元素。List接口和Set接口是Collection集合類的子接口,其中List接口的常用實現(xiàn)類有ArrayList類、Vector類和LinkedList類;Set接口的常用實現(xiàn)類有HashSet類和TreeSet類
    2021-11-11

最新評論