Grails闪存范围 [英] Grails flash scope
问题描述
def activeMember = {ConfirmSignUpCommand signupCommand - >
flash.signupCommand = signupCommand
render(view:confirmPassword)
}
当confirmPassword.gsp上的表单被提交时,它通过以下操作来处理:
def validatePasswordConfirmation = {
def password = params.password
def command = flash.signupCommand
}
但是,当我到达validatePasswordConfirmation操作时,闪存范围为空。我100%确定在这两个控制器操作之间没有提交任何请求。我的闪光范围对象在哪里去了?
Flash对象可用于下一个请求,在您的场景中呈现confirmPassword.gsp页面很多时候它也用于通过重定向将对象传递给另一个控制器)。当confirmPassword.gsp页面提交这是另一个请求,并且您放置在Flash中的对象被自动清除。
In my Grails app I have a controller action that does this:
def activeMember = {ConfirmSignUpCommand signupCommand ->
flash.signupCommand = signupCommand
render(view: "confirmPassword")
}
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
}
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?
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屋!