【问题标题】:Difference between org/springframework/web/servlet/ModelAndView class and org/springframework/web/portlet/ModelAndView [duplicate]org/springframework/web/servlet/ModelAndView 类和 org/springframework/web/portlet/ModelAndView 之间的区别 [重复]
【发布时间】:2015-07-08 17:28:41
【问题描述】:

我刚刚回答了以下围绕这个已发布问题的问题。

spring mvc InternalResourceViewResolver doesnt get prefix

有人能分辨出这两个类之间的区别吗

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

我看到两者的 API 文档几乎相似

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.

但后者在解析视图中不起作用?

【问题讨论】:

    标签: java spring-mvc jakarta-ee spring-web


    【解决方案1】:

    忽略这两个是针对两个完全不同的环境,区别在于org.springframework.web.servlet.ModelAndViewsupported handler method return type

    • 一个ModelAndView 对象,模型隐含地丰富了命令对象和@ModelAttribute 带注释的参考数据访问器方法的结果。

    这意味着 Spring 有一个 HandlerMethodReturnValueHandler 实现 (ModelAndViewMethodReturnValueHandler),它将接收 ModelAndView 类型的返回值并对其进行处理。

    默认注册的org.springframework.web.portlet.ModelAndView没有这样的实现。

    更多:

    【讨论】:

    • 感谢您的回答。
    猜你喜欢
    • 2015-05-01
    • 2020-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-04
    • 2016-11-25
    • 2010-11-09
    • 1970-01-01
    相关资源
    最近更新 更多