*
The moose likes Spring and the fly likes what objects can we return from the methods of controller? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "what objects can we return from the methods of controller?" Watch "what objects can we return from the methods of controller?" New topic
Author

what objects can we return from the methods of controller?

Twoz Lee
Greenhorn

Joined: Aug 12, 2009
Posts: 6
Dear all,

usually the return object from the method in controller class are ModelAndView.

I just wonder what kind of object, we can return and can we redirect to other path in controller.

Also, I wonder where we can obtain the information.

Marc Cracco
Ranch Hand

Joined: Mar 09, 2010
Posts: 79
    
    1
Twoz Lee wrote:Dear all,

usually the return object from the method in controller class are ModelAndView.

I just wonder what kind of object, we can return and can we redirect to other path in controller.

Also, I wonder where we can obtain the information.



I'm not sure which methods in your controller class you're referring to. For example if you're using a SimpleFromController and handleRequest() then it is
an implementation of org.springframework.web.servlet.mvc.Controller Interface and the API is :

Method Summary

ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
Process the request and return a ModelAndView object which the DispatcherServlet will render.

So all you can return is a ModelAndView... or a subclass
I believe it's the same for onSubmit()...

Is that what you were looking for?


Spring Framework Doc 2.5.6

Marc


SCJP 6 [ My stuff ]
Twoz Lee
Greenhorn

Joined: Aug 12, 2009
Posts: 6
Marc Cracco wrote:

I'm not sure which methods in your controller class you're referring to. For example if you're using a SimpleFromController and handleRequest() then it is
an implementation of org.springframework.web.servlet.mvc.Controller Interface and the API is :

Method Summary

ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
Process the request and return a ModelAndView object which the DispatcherServlet will render.

So all you can return is a ModelAndView... or a subclass
I believe it's the same for onSubmit()...

Is that what you were looking for?


Spring Framework Doc 2.5.6

Marc



i use annotation - Controller , so i do not extends different SimpleFromController or other controllers

btw, where do you get the information that we can return ModelAndView and its subclass.

and also in the example method that which includes HttpServletRequest, HttpServletResponse .

where do you get the information in which documents?

Marc Cracco
Ranch Hand

Joined: Mar 09, 2010
Posts: 79
    
    1
I'm not sure I understand exactly what you're looking for... Can you give me more information as to what exactly you're doing. Also you ask where I get my information? In the Documentation I included the link to in my last post.
 
jQuery in Action, 2nd edition
 
subject: what objects can we return from the methods of controller?