Grails编译错误:无法解析类JSON

时间:2012-04-19 18:05:56

标签: java eclipse json grails

我有以下设置,grails 2.0.3,STS,我在我的一个控制器中执行此操作:

render(['car': contactL] as JSON)

运行应用程序时出现以下错误:

我已经阅读了有关错误的内容,但没有一个解决方案对我有用,我尝试使用Grails工具进行清理,升级 - >刷新依赖关系,但它给了我:

grails> | Error Error running script null: Cannot invoke method trim() on null object (Use --stacktrace to see the full trace)

我的项目中也出现了这个错误:

The project was not built since its build path is incomplete. Cannot find the class file for groovy.lang.GroovyObject. Fix the build path then try building this project    Ristretto       Unknown Java Problem

你诊断的是什么?

2 个答案:

答案 0 :(得分:13)

要修复“无法解析类JSON”错误,您只需要导入它:

import grails.converters.JSON
...
class MyController {
    ...
    render [car: contactL] as JSON

答案 1 :(得分:0)

我终于设法让它工作,我切换了工作区,并添加了我的项目 - 解决了问题。