Grails 3.3.9:转发副本参数

时间:2019-02-08 14:30:50

标签: grails grails-controller grails3 grails-3.3 grails-3.3.x

我们正在从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函数设置一个标志,以便不将参数传递给重定向控制器?

1 个答案:

答案 0 :(得分:0)

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

forward controller: 'foo', action : 'bar'
相关问题