gpt4 book ai didi

grails - Grails 3.3.9:转发副本参数

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

我们正在从Grails 2.x迁移到3.x。使用转发功能时,我可以观察到一些不同的行为:

class FooController {

def index() {
forward controller: 'foo', action : 'bar', params: params
}

def bar() {
render(
view: "/foo/foo"
)
}
}

当调用 http://localhost:8080/foo?test=1并暂停 bar()方法时,我可以看到 params看起来像这样:
params = {GrailsParameterMap@11597}  size = 4
0 = {LinkedHashMap$Entry@11607} "test" ->
key = "test"
value = {String[2]@11612}
0 = "1"
1 = "1"
1 = {LinkedHashMap$Entry@11608} "controller" -> "foo"
2 = {LinkedHashMap$Entry@11609} "format" -> "null"
3 = {LinkedHashMap$Entry@11610} "action" -> "bar"

如您所见, test的值被保存为 String[]两次。此行为与Grails 2.5.6中的行为不同。
有什么方法可以为Grails forward函数设置一个标志,以便不将参数传递给重定向 Controller ?

最佳答案

我认为您不需要添加paramforward自动转发您的参数。它是可选的。如果添加它,它将复制这些值。仅尝试:

forward controller: 'foo', action : 'bar'

关于grails - Grails 3.3.9:转发副本参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54594559/

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