Grails SubFlow不会渲染其视图页面并返回HTTP 404

时间:2014-11-06 14:02:32

标签: grails groovy grails-plugin spring-webflow

我正在使用 Grails 2.3.6 并安装了 WebFlow 2.0.8.1 插件。我正在尝试使用SubFlow进行概念验证。在查看示例SubFlow documented here之后,我很难让简单的SubFlow工作。

注意:我是Grails和WebFlow的新成员。

这是我的项目结构:

Project Structure

HelloController呈现此页面:

HelloController Page

DemoController呈现此页面:

DemoController Page

然而,当我点击HelloController页面上的转到子流按钮时,我得到一个404:

enter image description here

如果我提供/hello/hello/subflowDemo.gsp,则页面呈现但不是来自DemoController的页面。

我做错了什么?

HelloController中

package helloworld

class HelloController {
    def helloFlow = {
        hello {
            on("goToSub").to "subflowDemo"
        }
        subflowDemo {
            subflow(controller: "demo", action: "demo")
        }
    }
}

hello.gsp

<html>
<body>
    Hello world!
    <g:form>
        <g:submitButton name="goToSub" value="Go To Sub Flow" />
    </g:form>
</body>
</html>

DemoController

package helloworld

class DemoController {
    def demoFlow = {
        demo {
        }
    }
}

demo.gsp

<html>
<body>
    This is the demo screen!
</body>
</html>

1 个答案:

答案 0 :(得分:1)

您必须完成流程循环。我认为子流的状态不能是主流的最终状态。所以结束主要流程中的流程。

以下代码更改对我有用,

HelloController.groovy

class HelloController {

    def helloFlow = {
        hello {
            on("goToSub").to "subflowDemo"
        }
        subflowDemo {
            subflow(controller: "demo", action: "demo")
            on("gotomainflow").to "endstate" // have a transition to endstate

        }
        endstate {

        }
    }

}

view / hello / hello / endstate.gsp中的endstate.gsp

<html>
<body>
    Came Back to main- endstate
</body>
</html>

DemoController.groovy

class DemoController {
    def demoFlow = {
        demo {
            on("gotomainflow").to "gotomainflow" //have the transition which calls a event
        }
        gotomainflow() // this event will trigger the event in the main flow
    }
}
在views / demo / demo /

中的

demo.gsp

<html>
<body>
    This is the demo screen!
    <g:form>
        <g:submitButton name="gotomainflow" value="Go To Main Flow" />
    </g:form>
</body>
</html>