Announcement Announcement Module
Collapse
No announcement yet.
How to redirect to next controller ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment

    Working...
    X