@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");

//		String action = request.getParameter("action");
		HttpSession session =  request.getSession();
		String name = Util.nullToString(request.getParameter("username"));
		String pwd = Util.nullToString(request.getParameter("password"));


        logger.info("###################Login begin");
		ObjectMapper mapper = new ObjectMapper();
		Map result = new HashMap();


		try {
            User user = (User) session.getAttribute("fgzb_user");
            if(user != null) {
                request.getRequestDispatcher("/admin/index.jsp").forward(request,response);
                return;
            }

            ProfileManager manager = ProfileManager.getInstance();
            user = manager.findUserByName(name);
            if(user != null) {
                if(name.trim().equalsIgnoreCase(user.getName()) && MD5Util.getMD5String(pwd.trim()).equalsIgnoreCase(user.getPwd()) ) {
                    result.put("success",true);
                    result.put("user",name);
                    session.setAttribute("fgzb_user", user);
                    request.getRequestDispatcher("/admin/index.jsp").forward(request,response);
                    return;
                }else {
                    result.put("success",false);
                    result.put("msg","用户名或密码错误");
                    request.setAttribute("errorMsg","用户名或密码错误");
                    request.getRequestDispatcher("/login.jsp").forward(request,response);
                    return;
                }
            }else{
				result.put("success",false);
				result.put("msg","请先登录");
				request.setAttribute("errorMsg","用户名或密码，请先登录。");
				request.getRequestDispatcher("/login.jsp").forward(request,response);
				return;
			}
		}catch (SQLException e) {
            result.put("success",false);
            result.put("msg","系统出现错误");
            request.setAttribute("errorMsg","系统出现错误");
            request.getRequestDispatcher("/login.jsp").forward(request,response);
            return;
        } finally {
            logger.info("###################Login end");
			String out =mapper.writeValueAsString(result);
			PrintWriter pw =  response.getWriter();
			pw.print(out);
		}




	}