aspose file tools*
The moose likes Spring and the fly likes is it necessary that method of Controller Class of Spring should return a Model and View Object?  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "is it necessary that method of Controller Class of Spring should return a Model and View Object?  " Watch "is it necessary that method of Controller Class of Spring should return a Model and View Object?  " New topic
Author

is it necessary that method of Controller Class of Spring should return a Model and View Object?

Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 639
is it necessary that method of Controller Class of Spring should return a Model and View Object? if no then what else can this method have insted of returning model and view object
Prashant Chindhade
Ranch Hand

Joined: Jan 19, 2011
Posts: 77
hi Monica. Shiralkar,

No its not necessary that every time you should return ModelAndView object. you can also return Map or List.

and string(which will be accounted as view name).

Suppose you are doing Ajax call to controller and you want list of objects returned from controller than you need to put @RequestMapping annotation(if you are using Spring MVC 3.0 or above) before controller method name that you want to call.

thanks
Prashant
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: is it necessary that method of Controller Class of Spring should return a Model and View Object?