2016-04-12 11 views
0

Ich versuche, die Index-Aktion aufrufen und rufen Sie die Zählung Aktion und ich weiß nicht warum. Dies ist der Code in der urlmappingGrails URL-Mapping tun falsche Aktion Anruf

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

Warum gibt es eine? in "/ zählen?" Sie machen das Wort "count" optional, damit es passt, wenn nichts da ist. In der Tat, ich denke, du willst das loswerden? in allen $ id auch. – billjamesdev

Antwort

1

folgende Zuordnungen Versuchen:

"/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"] 
} 
+0

Danke, damit, funktioniert !! –

Verwandte Themen