基于javaweb+mysql的jsp+servlet员工出差请假考勤管理系统(java+jsp+layui+html+servlet+mysql)

基于javaweb+mysql的jsp+servlet员工出差请假考勤管理系统(java+jsp+layui+html+servlet+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的JSP+Servlet员工出差请假考勤管理系统(java+jsp+layui+html+servlet+mysql)

项目介绍

本项目为后台管理系统;

管理员角色包含以下功能:

登录,首页,考勤记录增删改查,假期申请记录增删改查,出差申请记录增删改查,加班申请记录增删改查,调休申请,考勤查询,查看考勤详情,员工管理增删改查等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目:否;

技术栈

HTML+JSP+CSS+JavaScript+LayUI+Servlet+Mysql

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中c3p0-config.xml与utils/C3P0Utils.java配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入http://localhost:8080/kaoqin 登录 管理员账号/密码:admin/123456
     */
    public KaoqinjiluAdd() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		String kaoqinshijian = request.getParameter("kaoqinshijian");
		String leibie = request.getParameter("leibie");
		String staff_name = request.getParameter("staff_name");
		String kaoqinshiduan = request.getParameter("kaoqinshiduan");
		String shuoming = request.getParameter("shuoming");
		String jiluren = request.getParameter("jiluren");
		Kaoqinjilu k = new Kaoqinjilu();
		k.setKaoqinshijian(kaoqinshijian);
		k.setLeibie(leibie);
		k.setStaff_name(staff_name);
		k.setKaoqinshiduan(kaoqinshiduan);
		k.setShuoming(shuoming);
		k.setJiluren(jiluren);
		KaoqinjiluService service = new KaoqinjiluService();
		try {
			service.add(k);
			Thread.sleep(3000);
			response.sendRedirect(request.getContextPath() + "/KaoqinjiluList");
		}catch (Exception e) {
			// TODO: handle exception
		}

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

/**
 * Servlet implementation class KaoqinjiluList
 */
public class KaoqinjiluList extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public KaoqinjiluList() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		KaoqinjiluService service = new KaoqinjiluService();
		String currentPageStr =request.getParameter("currentPage");
		if(currentPageStr==null) currentPageStr="1";
		int currentPage = Integer.parseInt(currentPageStr);
		int currentCount=4;
		Long count = null;
		PageBean<Kaoqinjilu> pageBean = null;
		List<Kaoqinjilu> kaoqinjiluList = null;
		try {
			pageBean = service.findPageBean(currentPage,currentCount);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

/**
 * Servlet implementation class JiaqishenqingList
 */
public class JiaqishenqingList extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public JiaqishenqingList() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		JiaqishenqingService service = new JiaqishenqingService();
		String currentPageStr =request.getParameter("currentPage");
		if(currentPageStr==null) currentPageStr="1";
		int currentPage = Integer.parseInt(currentPageStr);
		int currentCount=4;
		Long count = null;
		PageBean<Jiaqishenqing> pageBean = null;

/**
 * Servlet implementation class JiaqishenqingList
 */
public class JiaqishenqingList extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public JiaqishenqingList() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		JiaqishenqingService service = new JiaqishenqingService();
		String currentPageStr =request.getParameter("currentPage");
		if(currentPageStr==null) currentPageStr="1";
		int currentPage = Integer.parseInt(currentPageStr);
		int currentCount=4;
		Long count = null;
		PageBean<Jiaqishenqing> pageBean = null;
		List<Jiaqishenqing> jiaqishenqingList = null;
		try {
			pageBean = service.findPageBean(currentPage,currentCount);
			jiaqishenqingList = service.findAllJiaqishenqing();
			count = service.Count();
			request.setAttribute("pageBean", pageBean);		
			request.setAttribute("jiaqishenqingList", jiaqishenqingList);		
			request.setAttribute("count", count);
			request.getRequestDispatcher("view/views/kaoqin/jiaqishenqing.jsp").forward(request, response);
		}catch (SQLException e) {
			e.printStackTrace();
		}
	}

	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

/**
 * Servlet implementation class ChuchaishenqingList
 */
public class ChuchaishenqingList extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ChuchaishenqingList() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String staff_name = request.getParameter("staff_name");
		String shenqingshijian = request.getParameter("shenqingshijian");
		String begin = request.getParameter("begin");
		String end = request.getParameter("end");
		String tiaoxiushichang = request.getParameter("tiaoxiushichang");
		String tiaoxiuyuanyin = request.getParameter("tiaoxiuyuanyin");
			
		Tiaoxiushenqing t = new Tiaoxiushenqing();
		t.setBegin(begin);
		t.setEnd(end);
		t.setShenqingshijian(shenqingshijian);
		t.setStaff_name(staff_name);
		t.setTiaoxiushichang(tiaoxiushichang);
		t.setTiaoxiuyuanyin(tiaoxiuyuanyin);
		TiaoxiushenqingService service = new TiaoxiushenqingService();
		try {
			service.add(t);
			Thread.sleep(3000);
			response.sendRedirect(request.getContextPath() + "/TiaoxiushenqingList");
		}catch (Exception e) {
			// TODO: handle exception
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

			sb.append(tongxingrenyuan[i]).append(',');
		}
		sb.append(tongxingrenyuan[tongxingrenyuan.length-1]);
		Chuchaishenqing c = new Chuchaishenqing();
		c.setId(Integer.parseInt(id));
		c.setChuchaishijian(chuchaishijian);
		c.setChuchaitianshu(chuchaitianshu);
		c.setTongxingrenyuan(sb.toString());
		c.setMudidi(mudidi);
		c.setChuxingfangshi(chuxingfangshi);
		c.setShiyou(shiyou);
		ChuchaishenqingService service = new ChuchaishenqingService();
		try {
			service.update(c);
			Thread.sleep(3000);
			response.sendRedirect(request.getContextPath() + "/ChuchaishenqingList");
		}catch (Exception e) {
			// TODO: handle exception
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

/**
 * Servlet implementation class JiaqishenqingAdd
 */
public class JiaqishenqingAdd extends HttpServlet {

/**
 * Servlet implementation class JiabanshenqingList
 */
public class JiabanshenqingList extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public JiabanshenqingList() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		JiabanshenqingService service = new JiabanshenqingService();
		String currentPageStr =request.getParameter("currentPage");
		if(currentPageStr==null) currentPageStr="1";
		int currentPage = Integer.parseInt(currentPageStr);
		int currentCount=4;
		Long count = null;
		PageBean<Jiabanshenqing> pageBean = null;
		List<Jiabanshenqing> jiabanshenqingList = null;
		try {
			pageBean = service.findPageBean(currentPage,currentCount);
			jiabanshenqingList = service.findAllJiabanshenqing();
			count = service.Count();
			request.setAttribute("pageBean", pageBean);		
			request.setAttribute("jiabanshenqingList", jiabanshenqingList);		
			request.setAttribute("count", count);
			request.getRequestDispatcher("view/views/kaoqin/jiabanshenqing.jsp").forward(request, response);
		}catch (SQLException e) {
			e.printStackTrace();
		}}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
			request.getRequestDispatcher("view/views/kaoqin/jiabanshenqing.jsp").forward(request, response);
		}catch (SQLException e) {
			e.printStackTrace();
		}}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

/**
 * Servlet implementation class TiaoxiushenqingEdit
 */
public class TiaoxiushenqingEdit extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public TiaoxiushenqingEdit() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String id = request.getParameter("id");
		String staff_name = request.getParameter("staff_name");
		String shenqingshijian = request.getParameter("shenqingshijian");
		String begin = request.getParameter("begin");
		String end = request.getParameter("end");
		String tiaoxiushichang = request.getParameter("tiaoxiushichang");
		String tiaoxiuyuanyin = request.getParameter("tiaoxiuyuanyin");

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String id = request.getParameter("id");
		String staff_name = request.getParameter("staff_name");
		String shenqingshijian = request.getParameter("shenqingshijian");
		String begin = request.getParameter("begin");
		String end = request.getParameter("end");
		String tiaoxiushichang = request.getParameter("tiaoxiushichang");
		String tiaoxiuyuanyin = request.getParameter("tiaoxiuyuanyin");
		Tiaoxiushenqing t = new Tiaoxiushenqing();
		t.setBegin(begin);
		t.setEnd(end);
		t.setId(Integer.parseInt(id));
		t.setShenqingshijian(shenqingshijian);
		t.setStaff_name(staff_name);
		t.setTiaoxiushichang(tiaoxiushichang);
		t.setTiaoxiuyuanyin(tiaoxiuyuanyin);
		TiaoxiushenqingService service = new TiaoxiushenqingService();
		try {
			service.update(t);
			Thread.sleep(3000);
			response.sendRedirect(request.getContextPath() + "/TiaoxiushenqingList");
		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

		}catch (SQLException e) {
			e.printStackTrace();
		}}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

/**
 * Servlet implementation class TiaoxiushenqingEdit
 */
public class TiaoxiushenqingEdit extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public TiaoxiushenqingEdit() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String id = request.getParameter("id");
		String staff_name = request.getParameter("staff_name");
		String shenqingshijian = request.getParameter("shenqingshijian");
		String begin = request.getParameter("begin");
		String end = request.getParameter("end");
		String tiaoxiushichang = request.getParameter("tiaoxiushichang");
		String tiaoxiuyuanyin = request.getParameter("tiaoxiuyuanyin");
		Tiaoxiushenqing t = new Tiaoxiushenqing();
		t.setBegin(begin);
		t.setEnd(end);
public class StaffList extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public StaffList() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		StaffService service = new StaffService();
		String currentPageStr =request.getParameter("currentPage");
		if(currentPageStr==null) currentPageStr="1";
		int currentPage = Integer.parseInt(currentPageStr);
		int currentCount=4;
		Long count = null;
		PageBean<Staff> pageBean = null;
		List<Staff> staffList = null;
		try {
			pageBean = service.findPageBean(currentPage,currentCount);
			staffList = service.findAllStaff();
			count = service.Count();
			request.setAttribute("pageBean", pageBean);		
			request.setAttribute("shujuzidianList", staffList);		
			request.setAttribute("count", count);
			request.getRequestDispatcher("view/views/user/user/staff.jsp").forward(request, response);
		}catch (SQLException e) {
			e.printStackTrace();
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

 */
public class TiaoxiushenqingList extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public TiaoxiushenqingList() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		TiaoxiushenqingService service = new TiaoxiushenqingService();
		String currentPageStr =request.getParameter("currentPage");
		if(currentPageStr==null) currentPageStr="1";
		int currentPage = Integer.parseInt(currentPageStr);
		int currentCount=4;
		Long count = null;
		PageBean<Tiaoxiushenqing> pageBean = null;
		List<Tiaoxiushenqing> tiaoxiushenqingList = null;
		try {
			pageBean = service.findPageBean(currentPage,currentCount);
			tiaoxiushenqingList = service.findAllTiaoxiushenqing();
			count = service.Count();
			request.setAttribute("pageBean", pageBean);		
			request.setAttribute("tiaoxiushenqingList", tiaoxiushenqingList);		
			request.setAttribute("count", count);
			request.getRequestDispatcher("view/views/kaoqin/tiaoxiushenqing.jsp").forward(request, response);
		}catch (SQLException e) {
			e.printStackTrace();
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

			request.getRequestDispatcher("view/views/kaoqin/tiaoxiushenqing.jsp").forward(request, response);
		}catch (SQLException e) {
			e.printStackTrace();
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

/**
 * Servlet implementation class JiabanshenqingEdit
 */
public class JiabanshenqingEdit extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public JiabanshenqingEdit() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

/**
 * Servlet implementation class ChuchaishenqingAdd
 */
public class ChuchaishenqingAdd extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ChuchaishenqingAdd() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String chuchaishijian = request.getParameter("chuchaishijian");
		String chuchaitianshu = request.getParameter("chuchaitianshu");
		String[] tongxingrenyuan = request.getParameterValues("tongxingrenyuan");
		StringBuilder sb = new StringBuilder();
		String mudidi = request.getParameter("mudidi");
		String chuxingfangshi = request.getParameter("chuxingfangshi");
		String shiyou = request.getParameter("shiyou");
		for(int i = 0 ; i<tongxingrenyuan.length-1; i++) {
			sb.append(tongxingrenyuan[i]).append(',');
		}
		sb.append(tongxingrenyuan[tongxingrenyuan.length-1]);
		k.setKaoqinshijian(kaoqinshijian);
		k.setLeibie(leibie);
		k.setStaff_name(staff_name);
		k.setKaoqinshiduan(kaoqinshiduan);
		k.setShuoming(shuoming);
		k.setJiluren(jiluren);
		KaoqinjiluService service = new KaoqinjiluService();
		try {
			service.add(k);
			Thread.sleep(3000);
			response.sendRedirect(request.getContextPath() + "/KaoqinjiluList");
		}catch (Exception e) {
			// TODO: handle exception
		}

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

/**
 * Servlet implementation class KaoqinjiluList
 */
public class KaoqinjiluList extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public KaoqinjiluList() {
        super();

/**
 * 通用编码解决方案
 * 
 */
public class GenericEncodingFilter implements Filter {
	public void destroy() {
	}

	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		// 转型为与协议相关对象
		HttpServletRequest httpServletRequest = (HttpServletRequest) request;
		// 对request包装增强
		HttpServletRequest myrequest = new MyRequest(httpServletRequest);
		chain.doFilter(myrequest, response);
	}

	public void init(FilterConfig filterConfig) throws ServletException {
	}

}

// 自定义request对象
class MyRequest extends HttpServletRequestWrapper {

	private HttpServletRequest request;

	private boolean hasEncode;

	public MyRequest(HttpServletRequest request) {
		super(request);// super必须写
		this.request = request;
	}

	// 对需要增强方法 进行覆盖
	@Override
	public Map getParameterMap() {
		// 先获得请求方式
		String method = request.getMethod();
		if (method.equalsIgnoreCase("post")) {
			// post请求
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		JiaqishenqingService service = new JiaqishenqingService();
		String currentPageStr =request.getParameter("currentPage");
		if(currentPageStr==null) currentPageStr="1";
		int currentPage = Integer.parseInt(currentPageStr);
		int currentCount=4;
		Long count = null;
		PageBean<Jiaqishenqing> pageBean = null;
		List<Jiaqishenqing> jiaqishenqingList = null;
		try {
			pageBean = service.findPageBean(currentPage,currentCount);
			jiaqishenqingList = service.findAllJiaqishenqing();
			count = service.Count();
			request.setAttribute("pageBean", pageBean);		
			request.setAttribute("jiaqishenqingList", jiaqishenqingList);		
			request.setAttribute("count", count);
			request.getRequestDispatcher("view/views/kaoqin/jiaqishenqing.jsp").forward(request, response);
		}catch (SQLException e) {
			e.printStackTrace();
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

/**
 * Servlet implementation class KaoqinjiluEdit
 */
public class KaoqinjiluEdit extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
		String kaoqinshiduan = request.getParameter("kaoqinshiduan");
		String shuoming = request.getParameter("shuoming");
		String jiluren = request.getParameter("jiluren");
		Kaoqinjilu k = new Kaoqinjilu();
		k.setId(id);
		k.setKaoqinshijian(kaoqinshijian);
		k.setLeibie(leibie);
		k.setStaff_name(staff_name);
		k.setKaoqinshiduan(kaoqinshiduan);
		k.setShuoming(shuoming);
		k.setJiluren(jiluren);
		KaoqinjiluService service = new KaoqinjiluService();
		try {
			service.update(k);
			Thread.sleep(3000);
			response.sendRedirect(request.getContextPath() + "/KaoqinjiluList");
		}catch (Exception e) {
			// TODO: handle exception
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;


/**
 * 通用编码解决方案
 * 
 */
public class GenericEncodingFilter implements Filter {
	public void destroy() {
	}

	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		// 转型为与协议相关对象
		HttpServletRequest httpServletRequest = (HttpServletRequest) request;
		// 对request包装增强
		HttpServletRequest myrequest = new MyRequest(httpServletRequest);
		chain.doFilter(myrequest, response);
	}

	public void init(FilterConfig filterConfig) throws ServletException {
	}

}

// 自定义request对象
class MyRequest extends HttpServletRequestWrapper {

	private HttpServletRequest request;

	private boolean hasEncode;

	public MyRequest(HttpServletRequest request) {
		super(request);// super必须写
		this.request = request;
	}

	// 对需要增强方法 进行覆盖
	@Override
	public Map getParameterMap() {
		// 先获得请求方式
		String method = request.getMethod();
		if (method.equalsIgnoreCase("post")) {
			// post请求
			try {
				// 处理post乱码
				request.setCharacterEncoding("utf-8");
				return request.getParameterMap();
			} catch (UnsupportedEncodingException e) {
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String staff_name = request.getParameter("staff_name");
		String shenqingshijian = request.getParameter("shenqingshijian");
		String begin = request.getParameter("begin");
		String end = request.getParameter("end");
		String tiaoxiushichang = request.getParameter("tiaoxiushichang");
		String tiaoxiuyuanyin = request.getParameter("tiaoxiuyuanyin");
			
		Tiaoxiushenqing t = new Tiaoxiushenqing();
		t.setBegin(begin);
		t.setEnd(end);
		t.setShenqingshijian(shenqingshijian);
		t.setStaff_name(staff_name);
		t.setTiaoxiushichang(tiaoxiushichang);
		t.setTiaoxiuyuanyin(tiaoxiuyuanyin);
		TiaoxiushenqingService service = new TiaoxiushenqingService();
		try {
			service.add(t);
			Thread.sleep(3000);
			response.sendRedirect(request.getContextPath() + "/TiaoxiushenqingList");
		}catch (Exception e) {
			// TODO: handle exception
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

/**
 * Servlet implementation class ChuchaishenqingList
 */
public class ChuchaishenqingList extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ChuchaishenqingList() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		ChuchaishenqingService service = new ChuchaishenqingService();
		String currentPageStr =request.getParameter("currentPage");
		if(currentPageStr==null) currentPageStr="1";
		int currentPage = Integer.parseInt(currentPageStr);
		int currentCount=4;
		Long count = null;
		PageBean<Chuchaishenqing> pageBean = null;
		List<Chuchaishenqing> chuchaishenqingList = null;
		try {
			pageBean = service.findPageBean(currentPage,currentCount);
			chuchaishenqingList = service.findAllChuchaishenqing();
			count = service.Count();
			request.setAttribute("pageBean", pageBean);		
			request.setAttribute("chuchaishenqingList", chuchaishenqingList);		
		String mudidi = request.getParameter("mudidi");
		String chuxingfangshi = request.getParameter("chuxingfangshi");
		String shiyou = request.getParameter("shiyou");
		for(int i = 0 ; i<tongxingrenyuan.length-1; i++) {
			sb.append(tongxingrenyuan[i]).append(',');
		}
		sb.append(tongxingrenyuan[tongxingrenyuan.length-1]);
		Chuchaishenqing c = new Chuchaishenqing();
		c.setChuchaishijian(chuchaishijian);
		c.setChuchaitianshu(chuchaitianshu);
		c.setTongxingrenyuan(sb.toString());
		c.setMudidi(mudidi);
		c.setChuxingfangshi(chuxingfangshi);
		c.setShiyou(shiyou);
		ChuchaishenqingService service = new ChuchaishenqingService();
		try {
			service.add(c);
			Thread.sleep(3000);
			response.sendRedirect(request.getContextPath() + "/ChuchaishenqingList");
		}catch (Exception e) {
			// TODO: handle exception
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
package cn.itheima.web;

	// 对需要增强方法 进行覆盖
	@Override
	public Map getParameterMap() {
		// 先获得请求方式
		String method = request.getMethod();
		if (method.equalsIgnoreCase("post")) {
			// post请求
			try {
				// 处理post乱码
				request.setCharacterEncoding("utf-8");
				return request.getParameterMap();
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		} else if (method.equalsIgnoreCase("get")) {
			// get请求
			Map<String, String[]> parameterMap = request.getParameterMap();
			if (!hasEncode) { // 确保get手动编码逻辑只运行一次
				for (String parameterName : parameterMap.keySet()) {
					String[] values = parameterMap.get(parameterName);
					if (values != null) {
						for (int i = 0; i < values.length; i++) {
							try {
								// 处理get乱码
								values[i] = new String(values[i].getBytes("ISO-8859-1"), "utf-8");
							} catch (UnsupportedEncodingException e) {
								e.printStackTrace();
							}
						}
					}
				}
				hasEncode = true;
			}
			return parameterMap;
		}

		return super.getParameterMap();
	}

	@Override
	public String getParameter(String name) {
public class ChuchaishenqingAdd extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ChuchaishenqingAdd() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String chuchaishijian = request.getParameter("chuchaishijian");
		String chuchaitianshu = request.getParameter("chuchaitianshu");
		String[] tongxingrenyuan = request.getParameterValues("tongxingrenyuan");
		StringBuilder sb = new StringBuilder();
		String mudidi = request.getParameter("mudidi");
		String chuxingfangshi = request.getParameter("chuxingfangshi");
		String shiyou = request.getParameter("shiyou");
		for(int i = 0 ; i<tongxingrenyuan.length-1; i++) {
			sb.append(tongxingrenyuan[i]).append(',');
		}
		sb.append(tongxingrenyuan[tongxingrenyuan.length-1]);
		Chuchaishenqing c = new Chuchaishenqing();
		c.setChuchaishijian(chuchaishijian);
		c.setChuchaitianshu(chuchaitianshu);
		c.setTongxingrenyuan(sb.toString());
		c.setMudidi(mudidi);
		c.setChuxingfangshi(chuxingfangshi);
		c.setShiyou(shiyou);
		ChuchaishenqingService service = new ChuchaishenqingService();
		try {
			service.add(c);
			Thread.sleep(3000);
			response.sendRedirect(request.getContextPath() + "/ChuchaishenqingList");
		}catch (Exception e) {
			// TODO: handle exception
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值