O'Reilly logo

Spring MVC Beginner’s Guide by Amuthan G

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The redirect view

In a web application, URL redirection or forwarding are the techniques to move visitors to a different web page than the one they request. Most of the time, this technique is used after submitting a web form to avoid resubmission of the same form due to the event of pressing the browser's back button or refresh button. Spring MVC has a special View object called Redirectview to handle redirection and forwarding. To use Redirectview (org.springframework.web.servlet.view.Redirectview) with our controller, we simply need to return the target URL string with the redirection prefix from the controller. There are two redirection prefixes available in Spring MVC, as shown in the following code snippet:

return redirect:/products/productDetail ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required