How do I create a urlmapping that maps controller A essentially as controller B?
I thought something like this would work, but no dice.
"/my/"(controller: 'other', action: '*')
How do I create a urlmapping that maps controller A essentially as controller B?
I thought something like this would work, but no dice.
"/my/"(controller: 'other', action: '*')
When you specify a controller in UrlMappings, leave off the trailing "Controller" (e.g. "my"
, instead of "myController"
). You also need some way of choosing which action.
You probably want something like "/my/$action?"(controller: 'my')
, which maps urls like /my/foo
to the foo action in MyController. The trailing question mark means the action part of the url is optional; /my
will trigger MyController.index
.
Note that the grails convention is already to map /my
to MyController
with the default mapping "/$controller/$action?/$id?"{}
, so you don't need a special UrlMapping for your example. You might want to consider just using the defaults and follow the convention.