1.首先通过ServletContext获取context对象,调用context.getRequestDispatcher()方法进行转发
ServletContext context = this.getServletContext();
// System.out.println("进入了Demo04,然后转发到了Demo03");
context.getRequestDispatcher("/getp").forward(req,resp);
// /getp为转发的xml文件中的servlet-pattern路径地址
2.在xml中注册当前类,启动tomcat进行测试