I have this post method:
@PostMapping("/upload")
public String singleFileUpload(@RequestParam("file") MultipartFile file,RedirectAttributes redirectAttributes)
throws IOException {
ExecutorService service= Executors.newSingleThreadExecutor();
Future<String> future=service.submit(new Callable<String>() {
@Override
public String call() throws Exception {
//parse file
Thread.sleep(5000);
return "done";
}
});
String result=future.get();
service.shutdown();
return "redirect:uploadState";
}
I want to redirect to uploadState while executor parse my file and uploadState have long polling ajax to notify if parsing is done or not.Can help me with some hints.