java程序员兼职平台,java大学生校园兼职平台

  java程序员兼职平台,java大学生校园兼职平台

  

目录

一、项目运行二、效果图三、核心代码登录控制层管理员登录控制层提交个人简介控制层

 

  

一、项目运行

环境配置:

 

  JDK 1.8 Tomcat 8.5 MySQL Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

  项目技术:

  HTML Springboot SpringMVC MyBatis百里香JavaScript JQuery Ajax maven等等。

  

二、效果图

 

  

三、核心代码

 

  

登录控制层

/* * * * @作者yy * @描述登录* @日期2022。2 .17 */公共类LoginController扩展http servlet { @ Override protected void doGet(http servlet请求req,http servlet响应response)抛出io异常{ JSON对象JSON对象=新JSON对象();字符串username=req。getparameter(“用户名”);字符串password=req。getparameter(“password”);resp。setcharacterencoding(“UTF-8”);http会话session=req。getsession();if(字符串实用程序。为空(用户名) 字符串实用程序。为空(密码)){ JSON对象。put(《代码》,2000);jsonObject.put(flag , fail );jsonObject.put(user ,null);jsonObject.put(msg , usernameOrPasswordIsBank );//用户名密码不能为空resp.getWriter().print(JSON对象);返回;} password=mymd 5 util。加密(密码);System.out.println(密码);业务用户VO业务用户VO=新业务用户VO();businessUserVO.setUsername(用户名);businessUserVO.setPassword(密码);学生用户VO学生用户VO=新学生用户VO();studentUserVO.setUsername(用户名);studentUserVO.setPassword(密码);string flag 1=null string flag 2=null try { flag 1=business userdao。选择用户名(业务用户VO);如果(确定).equals(flag1)) {//企业用户名存在业务用户dto业务用户dto=业务用户Dao。选择(业务用户VO);if(商业用户do!=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实战之兼职平台系统的实现的文章就介绍到这了,更多相关Java兼职平台系统内容请搜索盛行IT以前的文章或继续浏览下面的相关文章希望大家以后多多支持盛行IT!

 

郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。

留言与评论(共有 条评论)
   
验证码: