Hi,

In section 13.5.3.2 of the Spring manual, it advises against creating instances of RedirectView directly in the controller like this:

Code:
View redirectView = new RedirectView("http://example.org");
return new ModelAndView(redirectView);
and suggests instead to use something like the following:

Code:
return new ModelAndView("redirect:http://example.org");
(Ideally, the URL should be injected into the controller, rather than a hard-coded String literal, as above). However, one advantage of the first approach is that I can easily customise the redirection, for example by calling one of the following methods

  • RedirectView.setContextRelative()
  • RedirectView.setExposeModelAttributes()


Is it possible to perform the same customisation when using the second (recommended) approach?

Thanks in advance,
DM