spring mvc 的 controller,对于一个非常耗时的处理,让 controller 先异步返回响应给前端,后台继续慢慢执行完。
@RequestMapping(value = "refreshScore.do", method = RequestMethod.POST) public String refreshScore(HttpServletRequest request){ Map<String, Object> paramMap = DataConvertUtil.convertRequestParam(request); try{ // 刷新 paramMap.put("year", DateUtil.getCurrentYear()); // SCORE_YEAR paramMap.put("month", DateUtil.getMonth(new Date())); // SCORE_MONTH CompletableFuture future = CompletableFuture.runAsync(() -> { scoreCheckBiz.refreshScore(paramMap); }).thenAccept(e->System.out.println(e));//thenAccept接口完成处理结果 }catch(Exception e){ e.printStackTrace(); } return "OK!"; }
标签:DateUtil,异步,spring,refreshScore,mvc,paramMap From: https://www.cnblogs.com/moonsoft/p/16877091.html