gpt4 book ai didi

grails - Grails SubFlow不呈现其 View 页面并返回HTTP 404

转载 作者:行者123 更新时间:2023-12-02 14:07:16 24 4
gpt4 key购买 nike

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

注意:我通常是Grails和WebFlow的新手。

这是我的项目结构:
HelloController呈现此页面:
DemoController呈现此页面:

但是,当我单击HelloController页面上的转到子流按钮时,我得到了404:

如果我提供/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>

最佳答案

您必须完成流程。我相信子流的状态不能是主流的结束状态。因此,在主流中结束流。

以下代码更改对我有用,

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>

关于grails - Grails SubFlow不呈现其 View 页面并返回HTTP 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26781369/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com