Spring MVC 中的 ModelAndView 在 Play 框架中有等效项吗
does ModelAndView from Spring MVC have an equivalent in Play framework
ModelAndView 在 Play 框架中是否有直接的等效项,如果没有,我如何在使用此 class 的 Play 中重新创建 SpringMVC 代码,他们的一些简单代码是否可以做到这一点?
不是像 ModelAndView 这样的单一容器。 ModelAndView(基本上是 Map<String, Object>
)的目的主要是拥有一个容器,您可以在其中放置稍后在模板中使用的所有数据,并为每个数据片段命名。
在 Play 中,您只需直接为模板提供模板的所有对象。
Play 中的示例可能如下所示:
public Result index() {
// Somehow instantiate anObject and anotherObject
return ok(views.html.Controller.index(anObject, anotherObject));
}
您的模板 index.html.scala
将以以下内容开头:
@(anObject: AnObjectType, anotherObject: AnotherObjectType)
ModelAndView 在 Play 框架中是否有直接的等效项,如果没有,我如何在使用此 class 的 Play 中重新创建 SpringMVC 代码,他们的一些简单代码是否可以做到这一点?
不是像 ModelAndView 这样的单一容器。 ModelAndView(基本上是 Map<String, Object>
)的目的主要是拥有一个容器,您可以在其中放置稍后在模板中使用的所有数据,并为每个数据片段命名。
在 Play 中,您只需直接为模板提供模板的所有对象。
Play 中的示例可能如下所示:
public Result index() {
// Somehow instantiate anObject and anotherObject
return ok(views.html.Controller.index(anObject, anotherObject));
}
您的模板 index.html.scala
将以以下内容开头:
@(anObject: AnObjectType, anotherObject: AnotherObjectType)