javaEE 转发 和 重定向

转发 两种方法:

1,request.getRequestDispatcher(getServletContext().getContextPath() + "/path").forward(request, response);//request是HttpServletRequest的对象

2,this.getServletContext().getRequestDispatcher(getServletContext().getContextPath() + "/path").forward(request, response);

重定向

1,response.sendRedirect(getServletContext().getContextPath() + "/path"); //response是HttpServletResponse的对象

posted @ 2018-01-16 17:17  ytymz  阅读(197)  评论(0编辑  收藏  举报