Announcement Announcement Module
Collapse
No announcement yet.
Chaining controllers with Srping MVC Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Chaining controllers with Srping MVC

    A simple question,
    Is it possible to chaining action controllers together in Spring MVC, like the <forward> actions in Struts? The abstract controller action seems only return ModelAndView object.

    Thanks.

    -JJ

  • #2
    Take a look at org.springframework.web.servlet.view.RedirectView. You can do:

    Code:
    RedirectView next = new RedirectView&#40;"/next/url", true&#41;;
    return new ModelAndView&#40;next&#41;;
    Make sure that "/next/url" is mapped to the controller you want to chain to. You can add request parameters to the redirect by adding static attributes or query properties (see the Javadoc).

    Comment


    • #3
      Is there a forwardView?

      If I use redirect, I lose everything in my current Request context. Yes, I can put things in session, but that is not a good way to do things if I only want the attributes availabe in request scope.
      I guess that maybe I can directly use RequestDispatcher.forward() method. Has anybody tried this and see if it works?

      Thanks.

      Comment


      • #4
        Yes, you can use RequestDispatcher.forward().
        Your current Controller then has to return null instead of a ModelAndView-Object.

        Comment

        Working...
        X