一、项目结构
效果:
- 用ServletRefresh访问网页/refresh
- 然后会将请求转发到index.jsp页面
- 等待3秒后或者点击链接会自动刷新,跳转到首页home.html
二、ServletRefresh.Java
package net.test.servlet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(name = "ServletRefresh",urlPatterns = "/refresh")
public class ServletRefresh extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
protected void doGet(HttpServletRequest request, HttpServletResponse respon