hello
haha
@Autowired private BufferedRequestContext brc;
hello
public void execute(@Param("to") int toNumber) throws Exception { // 必须关闭buffering,未完成的页面才会被显示在浏览器上。 brc.setBuffering(false); // 设置content type,但不需要设置charset,框架会设置正确的charset。 response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<head>"); out.println(" <title>Count to " + toNumber + "</title>"); out.println("</head>"); out.println("<body>"); for (int i = 1; i <= toNumber; i++) { for (int j = 0; j < 10000; j++) { out.print(i); } out.println(); out.flush(); // 将当前的结果立即显示到浏览器上 Thread.sleep(1000); // 特意等待1秒,仅用于演示。 } out.println("</body>"); out.println("</html>"); }