Home > Back-end >  Web project create login servlet, using the correct password and account cannot log in, ask the grea
Web project create login servlet, using the correct password and account cannot log in, ask the grea

Time:09-15

@ WebServlet ("/login. Do ")
Public class UserLoginServlet extends the HttpServlet {
@ Override
Protected void doGet (it the req, HttpServletResponse resp) throws ServletException, IOException {
Enclosing the doPost (the req, resp);
}

@ Override
Protected void doPost (it the req, HttpServletResponse resp) throws ServletException, IOException {
String username=the req. GetParameter (" username ");
String userpwd=the req. GetParameter (" userpwd ");
Try {
UserLoginService UserLoginService=new UserLoginServiceImpl ();
The Users Users=userLoginService. UserLogin (username, userpwd);
//set up the client and server session state
The HttpSession session.=the req getSession ();
Session. SetAttribute (the USER_SESSION_KEY, users).
//using redirects to jump a homepage
Resp. SendRedirect (" main. JSP ");
} the catch (UserNotFoundException e) {
The req. SetAttribute (" MSG ", um participant etMessage ());
The req. GetRequestDispatcher (" login. JSP "). The forward (the req, resp);
} the catch (Exception e) {
Resp. SendRedirect (" error. JSP ");
}
}
}

CodePudding user response:

Light was not apparent to the code can not use the correct user name and password to log in

CodePudding user response:

Backend servlet interrupt point debugged, receives the username, userpwd is valid,
Page opening on F12 debugging, see if the Network and the Console is wrong,

CodePudding user response:

Background type breakpoints, step by step, look at where an error
  • Related