0

Please excuse me for my bad english. This is my problem using Spring MVC: Let assume that a user is clicking on a button and arrived to a route called "/randomRoute". I want him to have the possibility to keep doing his job (for example filling a form). About a certain amount of time (represented by the Thread.sleep in the thread), and whatever he did before, I want him to be redirected to a new route called "/newRandomRoute".

I thought about using Thread.run so that the user can continue his work until the delay is done but I don't know how to implement the redirect to the new route.

Is that possible with Spring? Or is there a way to change the url after the Thread.sleep method?

If you want more precision (I am trying to do something on the "Go to "newRandomRoute" page" comment:

@Controller
@RequestMapping("/home")
public class Chat {

    @GetMapping("/randomRoute")
    public String displayRandomRoute() {
        new Thread() {
            @Override
            public void run() {
                try {
                    Thread.sleep(5000);
                    // Go to "/newRandomRoute" newPage
                } catch (Exception e) {}
            }
        }.start();
        return "page";
    }

    @GetMapping("/newRandomRoute")
    public String displayNewRandomRoute() {
        return "newPage";
    }

}

Thanks for your help :)

0 Answers0