Should I be using @Controller classes when doing Spring web flow

It seems like I can do everything that the Controller class do inside Spring Web-Flow, for example decision making and switching from page to page. To my understanding, its the C inside the MVC model. Am I correct about this?

So my question is, is there any advantage to still include a Controller class when using Spring Web-Flow?


If you need access to the request and response, an appropriate design might still include a controller while also having a flow.xml. For example, if you had this code:

    HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getNativeRequest();
    HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getNativeResponse();

It's more intelligible to put that in a controller rather than a service.

Also, if you want to register a custom editor, it might make sense to have the controller have this logic in the initBinder() method.


Spring Web Flow uses the Spring MVC framework. The DispatcherServlet handles the request. A FlowHandlerMapping is used to map the request to a particular Web Flow.

Web Flow is to solve the problem involved with controller logic that spans multiple-page navigation (a pageflow, or wizard).

Web Flow can eliminate the need for specialized controller classes to accomplish following a path of page transitions/form updates along a predefined workflow. If you don't need to do this, you can save yourself a lot of configuration/complexity just by using MVC.

链接地址: http://www.djcxy.com/p/39106.html

上一篇: AngularJS + Karma(Testacular)

下一篇: 在做Spring web流程时,我应该使用@Controller类吗?