我玩弄grails但是在控制器中渲染JSON时我遇到了麻烦,我有这个代码
import grails.converters.*
class CourseController {
def index = { redirect(action:list,params:params) }
// the delete, save and update actions only accept POST requests
static allowedMethods = [delete:'POST', save:'POST', update:'POST']
def list = {
params.max = Math.min( params.max ? params.max.toInteger() : 10, 100)
//[ courseInstanceList: Course.list( params ) , courseInstanceTotal: Course.count() ]
def courses = Course.list( params )
// return a bunch of json data with metadata.
def json = [
totalCount: courses.size,
results: courses
]
render json as JSON
}
//other methods.... that i didn't touch
}
但是当我执行“run-app”命令时,我得到了一个错误的错误:
unable to resolve class org.codehaus.groovy.grails.co
mmons.metaclass.ExpandoMetaClass
@ line 4, column 1.
import org.codehaus.groovy.grails.commons.metaclass.ExpandoMetaClass
我真的不知道为什么:(
答案 0 :(得分:2)
看起来像Grails安装错误 - GRAILS_HOME设置正确吗?
或者是Groovy jar的冲突 - 类路径上有两个版本的Groovy吗?