1.创建Servlet类继承HttpServlet类
@WebServlet("/test12")
public class ServletTest12 extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("ServletTest12正在执行");
response.setContentType("text/html;charset=utf-8");
response.getWriter().print("访问成功");
//10秒后定时刷新,并且跳转到login页面
response.setHeader("Refresh","10;URL=/html/login.html");
}
}
2.通过浏览器访问服务器
1)服务器响应到浏览器信息
2)10秒后,自动刷新页面,跳转到login页面