1,ResponseRefresh Servlet实现定时刷新浏览器
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class ResponseRefresh extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setHeader("refresh", "5");//5秒定时刷新网页 response.setContentType("text/html;charset=UTF-8");//告诉浏览器以UTF-8码表打开 response.setCharacterEncoding("UTF-8");//以UTF-8码发送浏览器请求 response.getWriter().write("您好!!"); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } }