org/springframework/web/servlet/ModelAndView类与org/springframework/web/portlet/ModelAndView之间的区别 [英] Difference between org/springframework/web/servlet/ModelAndView class and org/springframework/web/portlet/ModelAndView

查看:147
本文介绍了org/springframework/web/servlet/ModelAndView类与org/springframework/web/portlet/ModelAndView之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚回答了以下有关此已发布问题的问题.

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

spring mvc InternalResourceViewResolver没有前缀

有人可以说出课程之间的区别

Can someone out there tell the difference between the classes

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

我都看到了几乎相似的API文档

I see almost similar API docs for both

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

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

都具有构造函数

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

而后者在解析视图时不起作用?

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

推荐答案

忽略这两个是针对两个完全不同的环境的,不同之处在于 org.springframework.web.servlet.ModelAndView 是支持处理程序方法返回类型:

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:

  • 一个 ModelAndView 对象,该模型隐含了命令对象和 @ModelAttribute 注释的参考数据访问器方法的结果.
  • A ModelAndView object, with the model implicitly enriched with command objects and the results of @ModelAttribute annotated reference data accessor methods.

这意味着Spring具有

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

它没有默认注册的 org.springframework.web.portlet.ModelAndView 的实现.

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

更多:

这篇关于org/springframework/web/servlet/ModelAndView类与org/springframework/web/portlet/ModelAndView之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆