org/springframework/web/servlet/ModelAndView类与org/springframework/web/portlet/ModelAndView之间的区别

编程入门 行业动态 更新时间:2024-10-27 17:16:30
本文介绍了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

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

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具有 HandlerMethodReturnValueHandler 实现( ModelAndViewMethodReturnValueHandler ),它将收到类型为 ModelAndView 并对其进行处理.

      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.

      更多:

      • Spring MVC既不是BindingResult也不是普通目标
      • HandlerMethodReturnValueHandler 工作?

更多推荐

org/springframework/web/servlet/ModelAndView类与org/springframework/web/portlet/Mo

本文发布于:2023-10-07 17:49:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1470082.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区别   web   springframework   org   portlet

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!