Redirect after request processing in Spring MVC controller

Spring MVC supports us to redirect to another request after processing the current request. In this tutorial, we will learn how to do what I just said.

As you know, after processing the request, the controller typically selects a view to display the returned data to the user. In case you want to redirect after processing a request, we just need to add “redirect:/” before the URL to redirect, then Spring will automatically redirect to the URL we want. Of course this URL must be in our system!

Take a look at this example:

In the above example, after processing the login request, our site will automatically redirect to the “/home” page.

Đánh giá bài viết
Chia sẽ bài viết này ...Share on Facebook
Facebook
0Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

Add Comment