grails - Grails 3-带过滤参数的前进

标签 grails parameters forward grails-controller

在我的Grails 3 Controller 中有两个 Action

def one() {
    forward([ action: 'two', params: [ a: 3 ] ])
}

def two() {
    println params
}

当我调用/myController/one?a=1时,打印的参数是
[a:[3, 1], controller:myController, action:two]

说我对这个结果感到有些惊讶,我通过如下更改one操作来进行操作
def one() {
    params.remove('a')
    println params
    forward([ action: 'two', params: [ a: 3 ] ])
}

结合在一起的两个println显示
[controller:myController, action:one]
[a:[3, 1], controller:myController, action:two]

后者又包括原始a参数的值和新的自定义值。

我的问题是:是否可以做一些事情来摆脱原始的值(value),而又没有采取丑陋的解决方法(例如为我的参数使用其他名称)?

最佳答案

我想Graeme Rocher的this comment解决了对整体可行性的任何疑问:

A forward is supposed to forward all of the origin params [...]

However there is no way with the way current servlets work to "override" a parameter, the originals are always retained on a forward.

关于grails - Grails 3-带过滤参数的前进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44890452/

相关文章:

facebook - 如何从 Grails 中的 Spring Security 的 Facebook 身份验证中获取 Facebook 用户名、电子邮件、电话号码等

rest - 向 Grails restfulcontroller 添加功能

ios - 如何通过addTarget传递方法参数

node.js - 使用用于 Nodejs 的 Neo4j-Driver 通过 id 和参数获取 Node

python - 如何摆脱 Python raw_input() 中的正斜杠

grails - 意外锁定协议(protocol) : Expected 3, 发现 49

javascript - jQuery 将参数传递到 ajax 成功的函数调用中

tomcat - request.getDispatcher ("/newurl").forward() 在使用通过ajp连接到tomcat的apache时会工作吗?

grails - 使用 Controller 提供的模型参数注入(inject) Grails 2.4.x i18n 消息