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

Time for action – examining RedirectView

Though both redirection and forwarding are used to present a different web page than the one requested, there is a little difference between them. Let's try to understand these by examining them:

  1. Open our HomeController class and add one more request mapping method as follows:
    @RequestMapping("/welcome/greeting")
    public String greeting() {
      return "welcome";
    }
  2. Now, alter the return statement of the existing welcome request mapping method, and save it as follows:
    return "forward:/welcome/greeting";
  3. Now, run our application and enter http://localhost:8080/webstore/. You will be able to see a welcome message on the web page.
  4. Now, alter the return statement of the existing welcome request mapping method again and ...

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