2
votes

I'm using Grails 2.1.0 and have a save() action on a controller, with two parameters:

def save(String templateId, String action)

When I submit a form with a field called "action" with the vaule "xxxx", and I println action, I get "save".

The doc says that the current action name should be on the actionName variable **, but it seems Grails is also putting the action name on my "action" variable.

Anyone knows why is that happening? Is it a bug or an expected behavior?

** http://grails.github.io/grails-doc/2.1.0/ref/Controllers/actionName.html

1

1 Answers

2
votes

That's from UrlMappings.groovy. The named variables in mapping config lines become variables in the params map, so this default mapping

"/$controller/$action?/$id?(.$format)?"{
    ...
}

will create a controller variable, and if there's an action specified it will be in the action variable, and if there's an id, id. The same goes for any variables you specify yourself, e.g.

"/api/v1.0/publish/$plugin/$version"(controller:"repository", action:"publish")

defines plugin and version variables.