2013-03-01 49 views
0

是什麼我做錯了,我無法給JSON對象Grails的控制器傳遞給Grails的服務無法從Grails的控制器傳遞的JSONObject到Grails的服務

class SampleController { 

    def sampleService 

    def updateProduct() { 
    def jq = request.JSON 
    sampleService(jq) 
    }  
} 

class SampleService { 

    def updateProduct (JSONObject requestJSON) { 
    if (!requestJSON) { 
     return null; 
    } 
    } 
} 

法無簽名:com.SampleService.call()適用於參數類型:(org.codehaus.groovy.grails.web.json.JSONObject)值:

可能的解決方案:

wait()any()wait(long)any(groovy.lang.Closure)each(groovy.lang.Closure),find()

Stacktrace如下:

+1

你發佈的堆棧跟蹤? – 2013-03-01 16:32:07

+0

錯誤2013-03-01 10:15:45,056 [http-bio-8080-exec-4] ERROR errors.GrailsExceptionResolver - 處理請求時發生MissingMethodException: 方法的無簽名:com.SampleService.call()適用於參數類型:(org.codehaus.groovy.grails.web.json.JSONObject)values:可能的解決方案:wait(),any(),wait(long),any(groovy.lang.Closure),each(groovy.lang .Closure),find()。 Stacktrace如下: – 2013-03-01 16:37:00

+1

我猜'sampleService(jq)'應該是'sampleService.updateProduct(jq)'。 – moeTi 2013-03-01 16:42:07

回答

2

您試圖將服務對象作爲方法調用。

sampleService(jq)應該sampleService.updateProduct(jq)

+0

Omg我怎麼錯過這個東西:)愚蠢的錯誤非常感謝您的快速回答。現在它的工作。 – 2013-03-01 16:46:32