我正在尝试在Spring MVC Controller方法上运行一个重复任务,并希望它返回/重定向到另一个MVC Controller方法,然后该方法将转到.jsp页面(如果给定给定值,则Runnable每5分钟检查一次值为true,如果发生这种情况,则应重定向到控制器方法,该方法将添加属性并转到.jsp页面):
@GetMapping("/startMonitoring")
public String startMonitoring(HttpServletRequest request, Model model){
Runnable helloRunnable = () -> {
List<Coin> listCoin = cDao.getCoins();
List reachedList = data.checkIfAllCoinsReached(listCoin, cDao);
//should add a model like this model.addAttribute("notification", reachedList);
//here it would need to go to a Controller method
};
future = executor.scheduleAtFixedRate(helloRunnable, 0, 5, TimeUnit.MINUTES);
String referer = request.getHeader("referer");
return "redirect:"+referer;
}
但是由于无法返回Runnable任务内的Controller方法/.JSP页面,我该怎么做?
谢谢。