Grails 闪存范围 [英] Grails flash scope
问题描述
在我的 Grails 应用程序中,我有一个执行此操作的控制器操作:
In my Grails app I have a controller action that does this:
def activeMember = {ConfirmSignUpCommand signupCommand ->
flash.signupCommand = signupCommand
render(view: "confirmPassword")
}
当confirmPassword.gsp 上的表单被提交时,它由以下动作处理:
When the form on confirmPassword.gsp is submitted it is handled by the following action:
def validatePasswordConfirmation = {
def password = params.password
def command = flash.signupCommand
}
但是,当我到达 validatePasswordConfirmation 操作时,闪存范围是空的.我 100% 确定在这两个控制器操作之间没有提交请求.我的闪光范围对象去哪儿了?
However, when I reach the validatePasswordConfirmation action the flash scope is empty. I'm 100% certain that there are no requests submitted between these two controller actions. Where has my flash-scoped object gone?
推荐答案
flash 对象将可用于下一个请求,在您的场景中,即 confirmPassword.gsp 页面的呈现(很多时候它也用于传递对象通过重定向到另一个控制器).当confirmPassword.gsp 页面提交时,是另一个请求,并且您放置在flash 中的对象会自动清除.
The flash object would be available to the next request, in your scenario that is the rendering of the confirmPassword.gsp page (many times it's also used to pass objects to another controller via a redirect). When the confirmPassword.gsp page submits that is another request and the object you placed in flash is cleared automatically.
这篇关于Grails 闪存范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!