我们正在从 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 中的行为不同。有没有办法为 Grailsforward
函数设置一个标志,以便不将参数传递给重定向控制器?