Announcement Announcement Module
No announcement yet.
Confusion about controllers! Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Confusion about controllers!

    Hello everyone,

    I hope someone can help me out. I am little confused about Controllers.
    A controllers job is it to take the request, prepare the data, add it to the request (with spring add it to new ModelView for example). Is this right?

    For example if i have a page to choose different operations. The next view is an input form which differs depending on which operation was choosen.

    chooseoperation.jsp -> input.jsp

    with adding controllers it would look something like this

    chooseoperation.jsp -> Controller (prepare data) -> input.jsp

    but if input.jsp contains a form. i need a forward to the InputFormController not the input.jsp itself, right?

    must look something like this:

    chooseoperation.jsp -> Controller (preparing information for input dialog) -> InputFormController - uses view -> input.jsp

    can i forward from a class implementing Controller to a SimpleFormController?

    big thx in advance

  • #2
    First of all, if you extend SimpleFormController this controller should prepare the data required to render the view with form. Have a look at the referenceData methods in SimpleFormController.

    Secondly, if your view can have multiple outcomes depending on which link or button you click on you can use MultiActionController. The methods on this controller can delegate to any controller you want, including a SimpleFormController.

    public class ... extends MultiActionController {
        private Controller someFormController = null;
        public void setSomeFormController(Controller ctrl) {
            this.someFormController = ctrl;
        public ModelAndView someAction(HttpServletRequest request, HttpServletResponse response) throws Exception {
            return this.someFormController.handleRequest(request, response);


    • #3
      thx a lot! i think this is the anser to my question ;-)

      this also means a controller is not neccessarly processed only bevore or after an jsp is visited. right?