哪个控制器变量应具有当前操作名称:action 或 actionName?
Which controller variable should have the current action name: action or actionName?
我正在使用 Grails 2.1.0 并且在控制器上有一个 save() 操作,有两个参数:
def save(String templateId, String action)
当我提交一个带有名为 "action" 的字段并带有值 "xxxx" 的表单并执行 println 操作时,我得到 "save".
文档说当前动作名称应该在 actionName 变量上**,但似乎 Grails 也将动作名称放在我的 "action" 变量上。
有人知道为什么会这样吗?这是错误还是预期行为?
** http://grails.github.io/grails-doc/2.1.0/ref/Controllers/actionName.html
来自 UrlMappings.groovy
。映射配置行中的命名变量成为 params
映射中的变量,因此此默认映射
"/$controller/$action?/$id?(.$format)?"{
...
}
将创建一个 controller
变量,如果指定了一个操作,它将在 action
变量中,如果有一个 id,则 id
。这同样适用于您自己指定的任何变量,例如
"/api/v1.0/publish/$plugin/$version"(controller:"repository", action:"publish")
定义 plugin
和 version
变量。
我正在使用 Grails 2.1.0 并且在控制器上有一个 save() 操作,有两个参数:
def save(String templateId, String action)
当我提交一个带有名为 "action" 的字段并带有值 "xxxx" 的表单并执行 println 操作时,我得到 "save".
文档说当前动作名称应该在 actionName 变量上**,但似乎 Grails 也将动作名称放在我的 "action" 变量上。
有人知道为什么会这样吗?这是错误还是预期行为?
** http://grails.github.io/grails-doc/2.1.0/ref/Controllers/actionName.html
来自 UrlMappings.groovy
。映射配置行中的命名变量成为 params
映射中的变量,因此此默认映射
"/$controller/$action?/$id?(.$format)?"{
...
}
将创建一个 controller
变量,如果指定了一个操作,它将在 action
变量中,如果有一个 id,则 id
。这同样适用于您自己指定的任何变量,例如
"/api/v1.0/publish/$plugin/$version"(controller:"repository", action:"publish")
定义 plugin
和 version
变量。