gpt4 book ai didi

grails - Grails:在Webflow结束时将参数从 Controller 传递到 Controller

转载 作者:行者123 更新时间:2023-12-02 15:11:33 25 4
gpt4 key购买 nike

是否可以在Webflow的结尾通过重定向传递“params”?基本上,此变量或参数从 Controller 传递到 Controller 的目的是这样的,我希望在 View 页面上有一个变量或$ {param.xyz}可用仅在完成流之后才是

 class Example1Controller{
def startFlow = {
begin {
....
}
....
....
finished {
action {
flash.message = 'success'
}
redirect(controller: 'example2', action: 'myaccount', params: [author: "Stephen King"])
}
}
}

其他 Controller
 class Example2Controller{
def myaccount() {
def here = $params.author
return [me:here]
}
}

GSP View
 <html>
<body>
<g:if test="${params.me}">
<p>This is what I want to display: **${me}**</p>
<p>But it must come from the first controller, from the flow.</p>
</g:if>
</body>
</html>

基本上,所有这些变量从 Controller 传递到 Controller 的目的是这样的。我只想在流程完成后在 View 页面上使用变量或$ {param。}。

最佳答案

您可以使用hiddenField

<g:hiddenField name="myField" value="myValue" />

您可以将值从 Example1Controller 传递给 Example1Gsp (作为hideenField),并且可以从该GSP中获得 Example2Controller 中的值。

关于grails - Grails:在Webflow结束时将参数从 Controller 传递到 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14529628/

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