异步 Servlet 都不懂,谈何 WebFlux?
系统运维 2025-10-10 11:44:31
0

复制@WebServlet(urlPatterns = "/sync") public class SyncServlet extends HttpServlet { @Override protected void doPost(HttpServletRequest request,异步 HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { long start = System.currentTimeMillis(); printLog(request, response); System.out.println("总耗时:" + (System.currentTimeMillis() - start)); } private void printLog(HttpServletRequest request, HttpServletResponse response) throws IOException { try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } response.getWriter().write("ok"); } } 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.