Grails的3.3.9:正副本PARAMS

问题描述 投票:0回答:1

我们从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功能,以没有得到传递给重定向控制器PARAMS?

grails grails-controller grails3 grails-3.3 grails-3.3.x
1个回答
0
投票

我认为你不需要添加paramforward自动转发您的参数。这是可选的。如果添加它,它会重复的值。试试只用:

forward controller: 'foo', action : 'bar'
© www.soinside.com 2019 - 2024. All rights reserved.