Grails url映射做错了动作调用

时间:2016-04-12 00:14:23

标签: grails url-mapping grails-2.5 urlmappings.groovy

我试图调用索引操作并继续调用计数操作,但我不知道原因。这是urlmapping

中的代码
group "/api/product",{
    "?"(controller: 'product', action: 'save', method: 'POST')
    "?"(controller: 'product', action: 'index', method: 'GET')
    "/$id?"(controller: 'product', action: 'delete', method: 'DELETE')
    "/$id?"(controller: 'product', action: 'update', method: 'PUT')
    "/$id?"(controller: 'product', action: 'show', method: 'GET')
    "/count?"(controller: 'product', action: 'count', method: 'GET')
}

1 个答案:

答案 0 :(得分:1)

尝试以下映射:

"/api/product/count"(controller:"product")
{
     action = [GET:"count"]
}

"/api/product/$id"( controller:"product")
{
     action = [GET: "show", PUT:"update",DELETE:"delete"]
}

"/api/product"( controller:"product")
{
     action = [GET: "index", POST:"save"]
}