如何在不使用重定向的情况下将整个模型从一个 Controller 传递到另一个 Controller ?
最佳答案
我为此挣扎了很长一段时间,所以决定回答我自己的问题......forward
很有可能方法。不像chain
方法,documentation没有提到model
属性,但[至少在 grails 2.1.1 中]它实际上是受支持的。
在 Controller 一中:
def model = [
firstname: params.firstname,
lastname: params.lastname
]
forward(controller:"controllerName",action:"index", model:model)
在 Controller 二中:
render (view: "/page.gsp")
在page.gsp
Welcome ${firstname} ${lastname},
...
就那么简单...
关于Grails:如何将整个模型从一个 Controller 转发到另一个 Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13457366/