简体   繁体   English

Grails中的JSON问题

[英]Problem with JSON in Grails

Im toying with grails but i'm having troubles when render JSON in the controller, i have this code 我正在玩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
}

But when i execute the "run-app" command i get the fallowing error: 但是,当我执行“ 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

i really don't know why :( 我真的不知道为什么:(

That looks like a Grails install error - is GRAILS_HOME set properly? 看起来像是Grails安装错误-GRAILS_HOME是否设置正确?

Or a clash of Groovy jars - are there two versions of Groovy on the classpath somehow? 还是Groovy罐子的冲突-类路径上是否有Groovy的两个版本?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM