Before the global interceptor settings are saved, the URL is stored in the session after the login address
Request is used only as a one-time requests if the page jumps a few times the original URL does not exist the suggestion exists session
@Override
public boolean prehandle (HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
System.out.println ("Intercept all spring MVC requests");
User user = (user) request.getsession (). getattribute ("user");
if (user==null) {
User not logged in
String URL = Request.getrequesturi ();
First clear the previous URL session
try {
Request.getsession (). removeattribute ("url");
} catch (Exception e) {
Todo:handle exception
}
Keep the address before it expires
Request.getsession (). SetAttribute ("url", url);
Response.sendredirect (Request.getcontextpath () + "/failure.jsp");
return false;
}
return true;
}
Resolve the page after the session expires after landing and returning to the previous