简体   繁体   English

Grails 3.3.9:转发副本参数

[英]Grails 3.3.9: Forward copies params

We're migrating from Grails 2.x to 3.x. 我们正在从Grails 2.x迁移到3.x。 I can observe some different behaviour when using the forward function: 使用转发功能时,我可以观察到一些不同的行为:

class FooController {

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

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

When calling http://localhost:8080/foo?test=1 and halting in the bar() method I can see that params looks like that: 当调用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"

As you can see the value of test is saved twice as a String[] . 如您所见, test的值两次保存为String[] This behaviour is different than it used to be in Grails 2.5.6. 此行为不同于Grails 2.5.6中的行为。 Is there any way to set a flag to the Grails forward function in order to not get the params passed to the redirect controller? 有没有办法为Grails forward功能设置一个标志,以便不将参数传递给重定向控制器?

I think you don't need to add the param . 我认为您不需要添加param forward automatically forwards your parameters. forward自动转发您的参数。 It's optional. 它是可选的。 If you add it, it will duplicate the values. 如果添加它,它将复制这些值。 Try with only: 仅尝试:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM