【发布时间】:2019-02-08 14:30:49
【问题描述】:
我们正在从 Grails 2.x 迁移到 3.x。使用 forward 函数时,我可以观察到一些不同的行为:
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 函数设置一个标志,以免将参数传递给重定向控制器?
【问题讨论】:
标签: grails grails-controller grails3 grails-3.3 grails-3.3.x