javaEE 转发 和 重定向

Posted 李盘全

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的对象

以上是关于javaEE 转发 和 重定向的主要内容,如果未能解决你的问题,请参考以下文章