【问题标题】:Unable to pass JSONObject from Grails Controller to the Grails service无法将 JSONObject 从 Grails 控制器传递到 Grails 服务
【发布时间】:2013-03-01 16:30:52
【问题描述】:

我在这里做错了什么,我无法将 JSON 对象Grails 控制器 传递给 Grails 服务。 p>

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()

堆栈跟踪如下:

【问题讨论】:

  • 你会发布堆栈跟踪吗?
  • 错误 2013-03-01 10:15:45,056 [http-bio-8080-exec-4] 错误错误。GrailsExceptionResolver - 处理请求时发生 MissingMethodException:没有方法签名:com.SampleService。 call() 适用于参数类型:(org.codehaus.groovy.grails.web.json.JSONObject) 值:可能的解决方案:wait()、any()、wait(long)、any(groovy.lang.Closure) ,每个(groovy.lang.Closure),find()。堆栈跟踪如下:
  • 我猜sampleService(jq) 应该是sampleService.updateProduct(jq)

标签: json grails groovy


【解决方案1】:

您正在尝试将服务对象作为方法调用。

sampleService(jq) 应该是sampleService.updateProduct(jq)

【讨论】:

  • 天哪,我怎么会错过这件事 :) 愚蠢的错误 非常感谢您的快速回答。现在它的工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-02
相关资源
最近更新 更多