views:

56

answers:

1

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: '*')
+4  A: 

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.

ataylor
You're right. My example was exceptionally poor. It would only make sense if I was mapping MycontrollerController to MyController. :P
Stefan Kendall