Grails闪存范围 [英] Grails flash scope

查看:78
本文介绍了Grails闪存范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Grails应用程序中,我有一个控制器动作可以做到这一点:

  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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆