Grails - restful-api插件匹配url,但返回404

时间:2014-12-17 14:28:18

标签: rest grails grails-plugin restful-url

我正在尝试使用Grails的RESTful API插件创建一个restful api。我试图点击http://localhost:8080/grails-api/qapi/searchs?query=abc,但我收到的是404。这是怎么回事?

日志

DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [500]
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/]
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/qapi/(*)]
DEBUG mapping.DefaultUrlMappingsHolder  - Matched URI [/qapi/searchs] with pattern [/qapi/(*)], adding to posibilities
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/api/(*)]
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/api/(*)/(*)]
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/api/(*)/(*)/(*)]
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/(*)/(*)?/(*)?(.(*))?]
DEBUG mapping.DefaultUrlMappingsHolder  - Matched URI [/qapi/searchs] with pattern [/(*)/(*)?/(*)?(.(*))?], adding to posibilities
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/dbdoc/(*)?/(*)?/(*)?/(*)?]
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/api/(*)/(*)/(*)/(*)]
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/assets/(**)]
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [500]
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/]
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/qapi/(*)]
DEBUG mapping.DefaultUrlMappingsHolder  - Matched URI [/qapi/searchs] with pattern [/qapi/(*)], adding to posibilities
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/api/(*)]
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/api/(*)/(*)]
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/api/(*)/(*)/(*)]
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/(*)/(*)?/(*)?(.(*))?]
DEBUG mapping.DefaultUrlMappingsHolder  - Matched URI [/qapi/searchs] with pattern [/(*)/(*)?/(*)?(.(*))?], adding to posibilities
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/dbdoc/(*)?/(*)?/(*)?/(*)?]
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/api/(*)/(*)/(*)/(*)]
DEBUG mapping.DefaultUrlMappingsHolder  - Attempting to match URI [/qapi/searchs] with pattern [/assets/(**)]
DEBUG filter.UrlMappingsFilter  - No match found, processing remaining filter chain

UrlMappings.groovy

"/$controller/$action?/$id?(.$format)?"{
    constraints {
        // apply constraints here
    }
}

// Default controller to handle RESTful API requests.
// Place URL mappings to specific controllers BEFORE this mapping.
//
"/api/$pluralizedResourceName/$id"(controller:'restfulApi') {
    action = [GET: "show", PUT: "update",
              DELETE: "delete"]
    parseRequest = false
    constraints {
        // to constrain the id to numeric, uncomment the following:
        // id matches: /\d+/
    }
}
"/api/$pluralizedResourceName"(controller:'restfulApi') {
    action = [GET: "list", POST: "create"]
    parseRequest = false
}

// Support for nested resources. You may add additional URL mappings to handle
// additional nested resource requirements.
//
"/api/$parentPluralizedResourceName/$parentId/$pluralizedResourceName/$id"(controller:'restfulApi') {
    action = [GET: "show", PUT: "update", DELETE: "delete"]
    parseRequest = false
    constraints {
        // to constrain the id to numeric, uncomment the following:
        // id matches: /\d+/
    }
}

"/api/$parentPluralizedResourceName/$parentId/$pluralizedResourceName"(controller:'restfulApi') {
    action = [GET: "list", POST: "create"]
    parseRequest = false
}

"/qapi/$pluralizedResourceName"(controller:'restfulApi') {
    action = [GET: "list", POST: "search"]
    parseRequest = false
}

"/"(view:"/index")
"500"(view:'/error')

0 个答案:

没有答案