我在控制器中添加任何内容时出现错误

时间:2015-09-28 14:22:04

标签: grails grails-2.5

我在Windows 7 64位上使用Grails 2.5.1,使用Grails命令生成控制器和视图后

generate-all "*"

当我在控制器中添加任何新行时,我收到以下错误:

  

编译错误:启动失败:       E:\ Development \ eclipse \ TekDays \ grails- app \ controllers \ com \ tekdays \ TekEventController.groovy:47:模糊表达式可以是无参数闭包表达式,孤立的开放代码块,或者它可以继续前一个语句;解决方案:添加显式参数列表,例如{it - > ...},或通过给它一个标签强迫它被视为一个开放的块,例如L:{...},也可以删除上一个换行符,也可以添加一个明确的分号&#39 ;;' @第47行,第4栏。               {         ^       1错误

这是我的控制器:

package com.tekdays

import static org.springframework.http.HttpStatus.*

@Transactional(readOnly = true)
class TekEventController
{
def taskService // this what i added
static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"]

def index(Integer max)
{
    params.max = Math.min(max ?: 10, 100)
    respond TekEvent.list(params), model:[tekEventInstanceCount: TekEvent.count()]
}

def show(TekEvent tekEventInstance)
{
    respond tekEventInstance
}

def create()
{
    respond new TekEvent(params)
}

@Transactional
def save(TekEvent tekEventInstance)
{
    if (tekEventInstance == null)
    {
        notFound()
        return
    }

    if (tekEventInstance.hasErrors())
    {
        respond tekEventInstance.errors, view:'create'
        return
    }

    tekEventInstance.save flush:true
    taskService.addDefaultTasks(tekEventInstance) // this what i added
    request.withFormat
    {
        form multipartForm
        {
            flash.message = message(code: 'default.created.message', args: [message(code: 'tekEvent.label', default: 'TekEvent'), tekEventInstance.id])
            redirect tekEventInstance
        }
        '*' { respond tekEventInstance, [status: CREATED] }
    }
}

def edit(TekEvent tekEventInstance)
{
    respond tekEventInstance
}

@Transactional
def update(TekEvent tekEventInstance)
{
    if (tekEventInstance == null)
    {
        notFound()
        return
    }

    if (tekEventInstance.hasErrors())
    {
        respond tekEventInstance.errors, view:'edit'
        return
    }

    tekEventInstance.save flush:true

    request.withFormat
    {
        form multipartForm
        {
            flash.message = message(code: 'default.updated.message', args: [message(code: 'TekEvent.label', default: 'TekEvent'), tekEventInstance.id])
            redirect tekEventInstance
        }
        '*'
        {
            respond tekEventInstance, [status: OK]
        }
    }
}

@Transactional
def delete(TekEvent tekEventInstance)
{

    if (tekEventInstance == null)
    {
        notFound()
        return
    }

    tekEventInstance.delete flush:true

    request.withFormat
    {
        form multipartForm
        {
            flash.message = message(code: 'default.deleted.message', args: [message(code: 'TekEvent.label', default: 'TekEvent'), tekEventInstance.id])
            redirect action:"index", method:"GET"
        }
        '*'
        {
            render status: NO_CONTENT
        }
    }
}

protected void notFound()
{
    request.withFormat
    {
        form multipartForm
        {
            flash.message = message(code: 'default.not.found.message', args: [message(code: 'tekEvent.label', default: 'TekEvent'), params.id])
            redirect action: "index", method: "GET"
        }
        '*'
        {
            render status: NOT_FOUND
        }
    }
}
}

有什么建议可以解决这个错误吗? 感谢

0 个答案:

没有答案