Grails URL映射提供404

时间:2015-08-14 14:32:09

标签: grails url-mapping

这让我很疯狂:即使我确定我已经正确定义了这个自定义映射,它仍然保持404.

资源是嵌套的:发布者有多个频道,一个频道属于发布者。

我正在尝试进行一个AJAX调用,调用Channel控制器中的getMostRecentURLsWithoutChannels函数。

所需的网址格式为 / publishers / 1009303 / channels / getMostRecentURLsWithoutChannels

来自UrlMappings.groovy:

"/publishers"(resources: 'publisher') {
            "/configurations"(resources: "configuration")
            "/metadatas"(resources: "metadata")
            "/xpaths"(resources: "xpath")
            "/channels"(resources: "channel")
            "/crawlrequest"(resources: "crawlRequest")
        }

 "/publishers/${publisherId}/channels/getMostRecentURLsWithoutChannels"(controller: "channel", action: "getMostRecentURLsWithoutChannels", method: "GET")

UrlMappingsReport显示:

Controller: channel
 |   GET    | /publishers/${publisherId}/channels                                       | Action: index                                      |
 |   GET    | /publishers/${publisherId}/channels/create                                | Action: create                                     |
 |   POST   | /publishers/${publisherId}/channels                                       | Action: save                                       |
 |   GET    | /publishers/${publisherId}/channels/${id}                                 | Action: show                                       |
 |   GET    | /publishers/${publisherId}/channels/${id}/edit                            | Action: edit                                       |
 |   PUT    | /publishers/${publisherId}/channels/${id}                                 | Action: update                                     |
 |  PATCH   | /publishers/${publisherId}/channels/${id}                                 | Action: patch                                      |
 |  DELETE  | /publishers/${publisherId}/channels/${id}                                 | Action: delete                                     |
 |   GET    | /publishers/*/channels/getUrlsForChannel                                  | Action: getUrlsForChannel                          |
 |   GET    | /publishers/${publisherId}/channels/getMostRecentURLsWithoutChannels      | Action: getMostRecentURLsWithoutChannels 

在一般发布者/频道块的上方或下方移动自定义映射无效。

即使是createLink标记也能正确创建URL:

<g:createLink resource="publisher/channel" publisherId="${params.publisherId}" action="getMostRecentURLsWithoutChannels" />

结果 https://localhost:8443/publishers/1009303/channels/getMostRecentURLsWithoutChannels

控制器中的功能定义为:

def getMostRecentURLsWithoutChannels(Integer pub){..}

我错过了什么?

0 个答案:

没有答案