Intercept intercept point, if it returns True, the operation (successful interception) is not performed after the interception point
// returns false if you do not intercept
the HttpSession request.getSession the session = ();
// 1. intercept point: our project initiated the URL
String URI = Request.getRequestURI ();
// IF (!! session.getAttribute ( "the userInfo") = null || uri.indexOf ( "User / doLogin.do") = -. 1) {// the indexOf - path appears in the string subscript
IF (session.getAttribute ( "userInfo")! = null) {
// successful login, no interceptions.
to true return;
} the else {
// After intercepting the login page to enter
Response.sendRedirect (request.getContextPath () + "/ User / doLogin.do");
return to false;
}
Screenshot results: