Jsp/Servlet页面跳转

Jsp/Servlet页面跳转有两种,一种是Redirect(页面重定向),另一种是Forward(页面转发)。

Redirect:

response.sendRedirect("success.jsp");

完全跳转到一个新的请求,不共享之前Request中的数据。

Forward:

RequestDispatcher rd = request.getRequestDispatcher("ResultServlet");
rd.forward(request, response);

将当前请求转发到另一个请求中去,后一个请求共享先前一个请求的Request数据。

Posted in  java web


blog comments powered by Disqus
Fork me on GitHub