开发者

Creating a Grails URLMapping for all methods in a controller?

How do I create a urlmapping that maps controller A essentially as controller B?

I thought something like this would work, but no dic开发者_如何学JAVAe.

  "/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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜