调用response.redirect(),或者request.getRequestDispatcher(loginAddr).forward(request,response);后,后面的代码照样执行,虽然能转发到相应的页面,代码大概如下:

response.redirect("/login.jsp");
System.out.printLn("hello world!!");

上面的代码执行之后,控制台依然打印出hello world!!

同样的,下面的代码:

request.getRequestDispatcher(loginAddr).forward(request,response);
System.out.printLn("hello world!!");

上面的代码执行之后,控制台依然打印出hello world!!

要想让后面的代码不再执行,在后面写上return;

response.redirect("/login.jsp");
System.out.printLn("hello world!!");
return;

相关文章:

  • 2022-12-23
  • 2021-07-20
  • 2021-05-06
  • 2021-05-29
  • 2021-09-19
  • 2021-12-04
  • 2022-12-23
  • 2022-01-16
猜你喜欢
  • 2021-11-06
  • 2021-11-04
  • 2021-06-12
  • 2021-12-28
  • 2022-12-23
  • 2021-08-22
相关资源
相似解决方案