【发布时间】:2016-03-02 03:57:08
【问题描述】:
使用 Grails 进行以下 URL 映射
'/api/abcdef' (resources: 'abcDef')
'/api/abc' (resources: 'abc')
对/api/abcdef 的调用使用format 参数def 而不是AbcDefController 调用AbcController.index()。但是调用/api/abcdef/1 正确解析为AbcDefController.show()。这看起来像 grails url-mapping-report 会报告的错误
| GET | /api/abcdef | Action: index |
属于AbcDefController。
但是,如果将两个 URL 的顺序更改为
'/api/abc' (resources: 'abc')
'/api/abcdef' (resources: 'abcDef')
Grails 会正确地将 /api/abcdef 解析为 AbcDefController.index()。
但在任何一种情况下,/api/abc123 都会使用 format 参数 123 解析为 AbcController.index()
URL映射优先级的机制是什么?以上行为对吗?我使用 Groovy 2.4.5 和 Grails 2.5.3。
【问题讨论】:
-
您找到这个问题的答案了吗?如果是这样,我很高兴你能把它贴在这里。谢谢。
标签: grails url-routing