在 grails 中,如果我这样做:
def someAction() {
//.......
flash.message = "some message"
[:]
}
然后在 someAction.gsp 中,它会显示 flash 消息。
但是如果是这样的话:
def someAction() {
// ......
flash.message = "some message"
redirect uri: "${createLink(controller: 'someothercontroller', action: 'someotheraction')}"
}
那么在上面的例子中,在 someothereaction.gsp 中将没有 flash.message。
我的问题是如何将 flash.message
从 someAction 传递到 someotheraction(可能在其他 Controller 或同一 Controller 中)。
我知道我可以做类似 params.flash = flash.message
的事情,在其他操作中使用此 params.flash 分配给那里的 flash.message
。然而,在这种方法中,我必须始终知道所有可能并不总是发生的重定向。
那么有没有更好的,也许是“标准”的方法来保留 flash 消息直到最后一次重定向(最终呈现 gsp)?
最佳答案
关于flash - Grails 在重定向之间保留 Flash 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36937697/