我正在尝试将文件上传到我的grails控制器,然后使用上传的文件调用外部服务。这是我的控制器代码:
def detect() {
def f = request.getFile('img')
if (f.empty) {
respond 'Image cannot be empty'
return
}
def rest=new RestBuilder()
def resp = rest.post(...)
respond resp.json
}
但我得到以下例外:
| Error 2015-02-26 17:14:27,102 [http-bio-8080-exec-8] ERROR errors.GrailsExceptionResolver - HttpMessageNotWritableException occurred when processing request: [POST] /Twins/detection/detect
Could not write request: no suitable HttpMessageConverter found for request type [org.springframework.web.multipart.commons.CommonsMultipartFile]. Stacktrace follows:
Message: Could not write request: no suitable HttpMessageConverter found for request type [org.springframework.web.multipart.commons.CommonsMultipartFile]
这段代码有什么问题?