grailsweb流中的重定向

grailsweb流中的重定向,grails,spring-webflow,grails-2.0,grails-controller,Grails,Spring Webflow,Grails 2.0,Grails Controller,我对Grails web流中的重定向有疑问。 我处于视图状态,允许用户输入问题的答案。在两次错误的尝试中,我应该能够重新引导用户从不同的控制器查看页面。我的意思是 challengeQuestionOne{ onRender() { //Display question } on('next') {BuildQuestion command -> bind

我对Grails web流中的重定向有疑问。 我处于视图状态,允许用户输入问题的答案。在两次错误的尝试中,我应该能够重新引导用户从不同的控制器查看页面。我的意思是

challengeQuestionOne{
            onRender() {
                //Display question
            }
            on('next') {BuildQuestion command ->
                bindData(flow.recovery,command)
                [return the model to flow]
                if(command.hasErrors()) {
                    flow.command = command
                    return error()
                }
                if(check for status. If doesnot pass){
                    flash.message=message(code:'loginForm.account.locked', default: 'Please Contact Admin.')
                    redirect(controller : "login",action: "login")//how to redirect from here to diff controller
                }                    
                if (//compare answer entered) {

                }
                else{
                   //set status not active
                }

            }.to("challengeQuestionTwo")
            on(Exception).to("error")
            on('cancel').to('finish')                
        }

我已尝试从onRender重定向。它正在重定向到页面。但是如何在重定向页面上显示错误消息。如何将错误消息从一个控制器转发到另一个控制器???

在这种情况下,闪存示波器将无法按预期工作。 尝试使用另一种方法来显示错误。例如,您可以通过重定向传递参数。或者,您可以抛出一些异常并在呈现页面上检查它,如下所示:

<g:if test="${flowExecutionException}">
    <div class="error"><g:message code="loginForm.account.locked"/></div>
</g:if>

Ivo Houbrechts写了一篇关于grails webflow的优秀教程:

Webflow定义了自己的flash范围。尽管它与标准grails flash作用域具有相同的语义(主要目的是仅在下一个请求之后存储对象),但它是一个不同的作用域。这意味着webflow的flash作用域中存储的对象在标准grails操作中不可见

您可以在此处阅读更多内容:


Yaa…我使用了第一种方法,通过重定向发送参数。但是flowExecutionException看起来也不错。。。我会试试的
import org.springframework.web.context.request.RequestContextHolder
....
RequestContextHolder.currentRequestAttributes().flashScope.message = "YourMessage"