跳转到登录页面

1 在拦截器里拦截之后跳转到登录页
public class ActionInterceptor implements Interceptor {
@Override
public void intercept(Invocation inv) {
HttpSession session = inv.getController().getSession();
HttpServletRequest request = inv.getController().getRequest();
HttpServletResponse response = inv.getController().getResponse();
HttpSession httpSession = request.getSession();
Controller controller = inv.getController();
controller.redirect("/");
return;


或者是
request.getRequestDispatcher("../").forward(request,response);
 return;

或者是

response.sendRedirect("../");
 return;


 
原文地址:https://www.cnblogs.com/YangBinChina/p/13478724.html