【发布时间】:2016-02-27 17:19:21
【问题描述】:
使用 grails 3.0.9,我定义了 2 个域:
Game -> hasMany plays
Play -> belongsTo game
我已将以下内容添加到我的 UrlMappings.groovy 文件中。
"/games"(resources: "game") {
"/plays"(resources: "play")
}
使用 Postman,我在 http://localhost:8080/games 上做一个得到,我得到一个 404。
如果我删除 UrlMappings 并在 Game 域上放置一个 @Resource(uri='/games'),它将返回 200,正如预期的那样。这是我运行 url-mappings-report 时得到的结果:
Dynamic Mappings
| * | ERROR: 404 | View: /notFound |
| * | ERROR: 500 | View: /error |
| * | / | View: /index |
| * | /${controller}/${action}?/${id}?(.${format)? | Action: (default action) |
Controller: game
| GET | /games/create | Action: create |
| GET | /games/${id}/edit | Action: edit |
| POST | /games | Action: save |
| GET | /games | Action: index |
| DELETE | /games/${id} | Action: delete |
| PATCH | /games/${id} | Action: patch |
| PUT | /games/${id} | Action: update |
| GET | /games/${id} | Action: show |
Controller: play
| GET | /games/${gameId}/plays/create | Action: create |
| GET | /games/${gameId}/plays/${id}/edit | Action: edit |
| POST | /games/${gameId}/plays | Action: save |
| GET | /games/${gameId}/plays | Action: index |
| DELETE | /games/${gameId}/plays/${id} | Action: delete |
| PATCH | /games/${gameId}/plays/${id} | Action: patch |
| PUT | /games/${gameId}/plays/${id} | Action: update |
| GET | /games/${gameId}/plays/${id} | Action: show |
不确定为什么 UrlMappings 不起作用。
【问题讨论】:
标签: rest grails url-mapping grails-3.0