0

I have just answered the below question which revolves around this posted question.

spring mvc InternalResourceViewResolver doesnt get prefix

Can someone out there tell the difference between the classes

org/springframework/web/servlet/ModelAndView and org/springframework/web/portlet/ModelAndView

I see almost similar API docs for both

http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/servlet/ModelAndView.html

and

http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/portlet/ModelAndView.html

where both have the constructor

ModelAndView(String viewName)
Convenient constructor when there is no model data to expose.

and yet the latter doesn't work in resolving the view?

Community
  • 1
  • 1
Kalyan Chavali
  • 1,220
  • 7
  • 24

1 Answers1

1

Ignoring that these two are meant for two completely different environments, the difference is that org.springframework.web.servlet.ModelAndView is a supported handler method return type:

  • A ModelAndView object, with the model implicitly enriched with command objects and the results of @ModelAttribute annotated reference data accessor methods.

That means that Spring has a HandlerMethodReturnValueHandler implementation (ModelAndViewMethodReturnValueHandler) that will receive the return value of type ModelAndView and process it.

It does not have such a implementation for org.springframework.web.portlet.ModelAndView registered by default.

More:

Community
  • 1
  • 1
Sotirios Delimanolis
  • 252,278
  • 54
  • 635
  • 683