package com.bjsxt.controller;
import com.bjsxt.Employee;
import com.bjsxt.service.impl.UserServicelmpl;
import com.sun.net.httpserver.HttpServer;
import javax.jws.WebService;
import javax.servlet.ammotation.webServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.ServletException;
import javax.servlet.http.SttpServletRequest;
import javax.servlet.http.Http.HttpServletRespomse;
import javax.io.IoeXCEPTION;
import java.io.IOException;
@WebServlet("/userServlet");
public class UserServlet<employee> extends HttpServlet {
@Override
protected void service(HttpServletRequest req,HttpServletResponse resp)throws servletException, IOException
req.setCharactterEncoding("utf-8");
resp.setCometentType("text/html;charset=utf-8");
resp.setContentType("utf-8");
String empid = req.getParameter(s:"empid");
String password =req.getParameter(s:"password");
UserServlet userServlet = new UserServicelmpl();
Employee employee = userServlet.empLoginService(empid,password);
if(employee != null){
req.getSession().setAttibute(s:"emp",employee);
resp.sendRedirect(s:req.getContextPath()+"/main.jsp");
}else{
req.setAttribute(s:"flag",o:"用户名或密码错误");
req.getRequestDispatcher(s:"/login/jsp").forward(req,resp);
}
}