servlet的转发(dispatcher)

  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    System.out.println("帮我办个事");
    System.out.println("不,我找个人帮你办");
    // servlet转发 将请求向下传递
    ServletContext application = this.getServletContext();
    RequestDispatcher rd = application.getRequestDispatcher("/abc");//括号内填写转发的目标servlet的urlPatterns
    rd.forward(request, response);
}
文章目录
|