String check_code = request.getParameter("verifycode");
String code = String.valueOf(request.getSession().getAttribute("CHECKCODE_SERVER"));
request.getSession().removeAttribute("CHECKCODE_SERVER");
if (!check_code.equalsIgnoreCase(code)){
request.setAttribute("login_msg","验证码错误!");
request.getRequestDispatcher("/login.jsp").forward(request,response);
return;
}
String username = request.getParameter("username");
String password = request.getParameter("password");
UserService us=new UserServiceImpl();
UserUP userUP = us.login(username, password);
if (userUP!=null){
request.getSession().setAttribute("userUP",userUP);
response.sendRedirect(request.getContextPath()+"/index.jsp");
}else {
request.setAttribute("login_msg","用户名或密码错误!");
request.getRequestDispatcher("/login.jsp").forward(request,response);
} |
|