基于javaweb+mysql的jsp+servlet校园招聘平台系统(java+mysql+jdbc+servlet+springmvc+html)
基于javaweb+mysql的jsp+servlet校园招聘平台系统(java+mysql+jdbc+servlet+springmvc+html)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的JSP+Servlet校园招聘平台系统(java+mysql+jdbc+servlet+springmvc+html)
一、项目简述 功能: 用户和企业用户的注册登录,简历的筛选查看搜索,应聘信息互动等等。
二、项目运行 环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
Jdbc+ Servlert + SpringMvc + Jsp + css + JavaScript + JQuery + Ajax + Fileupload等等
/**
* @Description
* @Date
*/
public class DownloadResumeFileController extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String fileName = req.getParameter("fileName");
String path = req.getServletContext().getRealPath("")+"/"+fileName; //默认认为文件在当前项目的根目录
FileInputStream fis = new FileInputStream(path);
resp.setCharacterEncoding("utf-8");
resp.setHeader("Content-Disposition", "attachment; filename="+fileName);
ServletOutputStream out = resp.getOutputStream();
byte[] bt = new byte[1024];
int length = 0;
while((length=fis.read(bt))!=-1){
out.write(bt,0,length);
}
out.close();
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doGet(req, resp);
}
}
/**
* @Description
* @Date
*/
public class DownloadBusinessController extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String fileName = req.getParameter("fileName");
String path = req.getServletContext().getRealPath("")+"/"+fileName; //默认认为文件在当前项目的根目录
FileInputStream fis = new FileInputStream(path);
resp.setCharacterEncoding("utf-8");
resp.setHeader("Content-Disposition", "attachment; filename="+fileName);
ServletOutputStream out = resp.getOutputStream();
byte[] bt = new byte[1024];
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doGet(req, resp);
}
}
/**
*/
public class BusinessRegisterController extends HttpServlet {
@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 = null;
try {
items = upload.parseRequest(req);
} catch (FileUploadException e) {
e.printStackTrace();
}
StringBuffer sb = new StringBuffer();
if (insert == 1){
jsonObject.put("code",2000);
jsonObject.put("msg","add success");
jsonObject.put("flag","success");
jsonObject.put("data",resume);
resp.getWriter().print(jsonObject);
}else {
jsonObject.put("code",2000);
jsonObject.put("msg","add fail");
jsonObject.put("flag","fail");
jsonObject.put("data",null);
resp.getWriter().print(jsonObject);
}
} catch (SQLException throwables) {
throwables.printStackTrace();
jsonObject.put("code",5000);
jsonObject.put("msg","server error");
jsonObject.put("flag","fail");
jsonObject.put("data",null);
resp.getWriter().print(jsonObject);
}
}else if (operate.equals("download")){//下载简历
String file = req.getParameter("file"); //客户端传递的需要下载的文件名
String path = req.getServletContext().getRealPath("")+"/"+file; //默认认为文件在当前项目的根目录
FileInputStream fis = new FileInputStream(path);
resp.setCharacterEncoding("utf-8");
resp.setHeader("Content-Disposition", "attachment; filename="+file);
ServletOutputStream out = resp.getOutputStream();
byte[] bt = new byte[1024];
int length = 0;
while((length=fis.read(bt))!=-1){
out.write(bt,0,length);
}
out.close();
}else if (operate.equals("findByRecruitInfoId")){
String recruitInfoId = req.getParameter("recuitInfoId");
System.out.println(recruitInfoId);
List<Resume> byRecruitInfoID = ResumeDao.findByRecruitInfoID(Integer.parseInt(recruitInfoId));
jsonObject.put("code",2000);
jsonObject.put("msg","success");
jsonObject.put("flag","success");
jsonObject.put("data",byRecruitInfoID);
resp.getWriter().print(jsonObject);
} else if (operate.equals("findByStuUsername")){
String studentUsername = req.getParameter("studentUsername");
List<Resume> byRecruitInfoID = ResumeDao.findByStudentUsername(studentUsername);
jsonObject.put("code",2000);
jsonObject.put("msg","success");
jsonObject.put("flag","success");
jsonObject.put("data",byRecruitInfoID);
resp.getWriter().print(jsonObject);
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);
}
} catch (FileUploadException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (SQLException throwables) {
throwables.printStackTrace();
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doGet(req, resp);
}
}
/**
*/
public class AdminVerifyController extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String username = req.getParameter("username");
String companyId = req.getParameter("companyId");
String passOrNot = req.getParameter("passOrNot");
JSONObject jsonObject = new JSONObject();
try {
int i = AdminDao.verifyCompanyRegister(username, companyId, passOrNot);
//int flag = AdminDao.passOrNot(username, companyId);
if (i == 1){
BusinessDao.registerFlag(companyId,passOrNot);//设置公司的信息已经验证
jsonObject.put("code",2000);
jsonObject.put("msg","verify success");
resp.getWriter().print(jsonObject);
return;
}else {
jsonObject.put("code",2000);
jsonObject.put("msg","verify fail");
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);
}
}
* @Description 登录
* @Date 2020.5.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)) {//企业用户名存在
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");//密码错误
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doGet(req, resp);
}
}
/**
*/
@MultipartConfig
public class ResumeController extends HttpServlet {
private static int MAX_POST_SIZE = 1024*1024*100;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
String operate = req.getParameter("operate");
JSONObject jsonObject = new JSONObject();
resp.setCharacterEncoding("UTF-8");
if (operate.equals("add")){//投递简历与上传简历文件
String studentName = req.getParameter("studentName");
String studentUsername = req.getParameter("studentUsername");
String recruitInfoId = req.getParameter("recruitInfoId");
String applyPosition = req.getParameter("applyPosition");
String phoneNum = req.getParameter("phoneNum");
String email = req.getParameter("email");
jsonObject.put("data",null);
resp.getWriter().println(jsonObject);
return;
}
} else{
String condition = req.getParameter("condition");
try {
List<RecruitInformation> list = RecruitInformationDao.selectListBySearch(condition);
jsonObject.put("code",2000);
jsonObject.put("flag","success");
jsonObject.put("msg","success");
jsonObject.put("data",list);
resp.getWriter().println(jsonObject);
return;
} catch (SQLException e) {
e.printStackTrace();
jsonObject.put("code",2000);
jsonObject.put("flag","fail");
jsonObject.put("msg","select fail");
jsonObject.put("data",null);
resp.getWriter().println(jsonObject);
return;
}
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doGet(req, resp);
}
}
/**
* @Description
* @Date
*/
public class RecruitInformationController extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String operate = req.getParameter("operate");
JSONObject jsonObject = new JSONObject();
resp.setCharacterEncoding("UTF-8");
System.out.println(operate);
if (operate.equals("add")){
String requirement = req.getParameter("requirement");
HttpSession session = req.getSession();
BusinessVO businessVO = (BusinessVO) session.getAttribute("businessUser");
String companyId = businessVO.getCompanyId();
String companyName = businessVO.getCompanyName();
String salary = req.getParameter("salary");
String deadLine = req.getParameter("deadLine");
String address = req.getParameter("address");
String applyPosition = req.getParameter("applyPosition");
RecruitInformation recruitInformation = new RecruitInformation();
recruitInformation.setRequirement(requirement);
recruitInformation.setCompanyId(companyId);
recruitInformation.setCompanyName(companyName);
recruitInformation.setSalary(salary);
recruitInformation.setDeadLine(deadLine);
recruitInformation.setAddress(address);
recruitInformation.setApplyPosition(applyPosition);
try {
int i = RecruitInformationDao.insert(recruitInformation);
if (i>0){
jsonObject.put("code",2000);
jsonObject.put("flag","success");//添加成功
jsonObject.put("msg","add success");
jsonObject.put("data",recruitInformation);
resp.getWriter().println(jsonObject);
return;
}
} catch (SQLException e) {
e.printStackTrace();
jsonObject.put("code",2000);
jsonObject.put("flag","fail");//添加失败
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doGet(req, resp);
}
}
/**
* @Description 登录
* @Date 2020.5.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;
/**
*/
public class SubmitResumeController extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
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();
String path = req.getServletContext().getRealPath("")+"/"+fileName; //默认认为文件在当前项目的根目录
FileInputStream fis = new FileInputStream(path);
resp.setCharacterEncoding("utf-8");
resp.setHeader("Content-Disposition", "attachment; filename="+fileName);
ServletOutputStream out = resp.getOutputStream();
byte[] bt = new byte[1024];
int length = 0;
while((length=fis.read(bt))!=-1){
out.write(bt,0,length);
}
out.close();
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doGet(req, resp);
}
}
/**
* @Description
* @Date
*/
public class DownloadBusinessController extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String fileName = req.getParameter("fileName");
String path = req.getServletContext().getRealPath("")+"/"+fileName; //默认认为文件在当前项目的根目录
FileInputStream fis = new FileInputStream(path);
resp.setCharacterEncoding("utf-8");
resp.setHeader("Content-Disposition", "attachment; filename="+fileName);
ServletOutputStream out = resp.getOutputStream();
byte[] bt = new byte[1024];
int length = 0;
while((length=fis.read(bt))!=-1){
out.write(bt,0,length);
}
out.close();
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
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);
}
} catch (FileUploadException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (SQLException throwables) {
throwables.printStackTrace();
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doGet(req, resp);
}
}
resp.setCharacterEncoding("UTF-8");
if (operate.equals("add")){//投递简历与上传简历文件
String studentName = req.getParameter("studentName");
String studentUsername = req.getParameter("studentUsername");
String recruitInfoId = req.getParameter("recruitInfoId");
String applyPosition = req.getParameter("applyPosition");
String phoneNum = req.getParameter("phoneNum");
String email = req.getParameter("email");
String attachmentResume = "文件名";
Resume resume = new Resume(studentUsername, Integer.parseInt(recruitInfoId), studentName, applyPosition, phoneNum, email, attachmentResume);
int insert = 0;
try {
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);
}else {
jsonObject.put("code",2000);
jsonObject.put("msg","add fail");
jsonObject.put("flag","fail");
jsonObject.put("data",null);
resp.getWriter().print(jsonObject);
}
} catch (SQLException throwables) {
throwables.printStackTrace();
jsonObject.put("code",5000);
jsonObject.put("msg","server error");
jsonObject.put("flag","fail");
jsonObject.put("data",null);
resp.getWriter().print(jsonObject);
}
}else if (operate.equals("download")){//下载简历
String file = req.getParameter("file"); //客户端传递的需要下载的文件名
String path = req.getServletContext().getRealPath("")+"/"+file; //默认认为文件在当前项目的根目录
FileInputStream fis = new FileInputStream(path);
resp.setCharacterEncoding("utf-8");
resp.setHeader("Content-Disposition", "attachment; filename="+file);
ServletOutputStream out = resp.getOutputStream();
byte[] bt = new byte[1024];
int length = 0;
while((length=fis.read(bt))!=-1){
out.write(bt,0,length);
}
out.close();
}else if (operate.equals("findByRecruitInfoId")){
String recruitInfoId = req.getParameter("recuitInfoId");
}
/**
*/
public class BusinessRegisterController extends HttpServlet {
@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 = null;
try {
items = upload.parseRequest(req);
} catch (FileUploadException e) {
e.printStackTrace();
}
StringBuffer sb = new StringBuffer();
String companyFile = null;
for (FileItem item : items) {
String name = item.getFieldName();
/**
*/
public class BusinessRegisterController extends HttpServlet {
@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 = null;
try {
items = upload.parseRequest(req);
} catch (FileUploadException e) {
e.printStackTrace();
}
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+"&&");
try {
List<RecruitInformation> list = RecruitInformationDao.selectListBySearch(condition);
jsonObject.put("code",2000);
jsonObject.put("flag","success");
jsonObject.put("msg","success");
jsonObject.put("data",list);
resp.getWriter().println(jsonObject);
return;
} catch (SQLException e) {
e.printStackTrace();
jsonObject.put("code",2000);
jsonObject.put("flag","fail");
jsonObject.put("msg","select fail");
jsonObject.put("data",null);
resp.getWriter().println(jsonObject);
return;
}
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doGet(req, resp);
}
}
/**
*/
@MultipartConfig