Results 1 to 2 of 2

Thread: How to redirect to next controller ?

  1. #1
    Join Date
    Nov 2005
    Posts
    7

    Default How to redirect to next controller ?

    Hi,

    All of the spring books I have seen, I always see that the controller action always returns a ModelAndView reference to a new Jsp page. Meaning see following example:--
    return new ModelAndView(getSuccessView(),"accountdetail",acco untdetail); This will display the accountdetail.jsp page. I do not want this to happen.

    What if at the end, I want to redirect the control to onSubmit method of new controller.

    In short how do i redirect the control from controller1.onSubmit to controller2.onSubmit ?

    thanks
    pp

  2. #2
    Join Date
    Aug 2004
    Location
    Hawaii, US
    Posts
    225

    Default

    There is no explicit configuration for controller chaining in Spring MVC.

    If you are trying to do a HTTP redirect, then it's pretty easy, as you can just do: new ModelAndView("redirect:/some/uri") or create an instance of a RedirectView.

    You can, however, simply use Dependency Injection to get controller2 into controller1, and call controller2.onSubmit() youself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •