groovy.lang.MissingPropertyException

时间:2015-07-13 19:15:21

标签: grails grails-domain-class grails-controller

我一直在尝试在grails上的groovy中使用动态脚手架来查看任务列表。我的域类如下

package projecttracker

import java.util.Date;

class Task 
{
    String name
    String description
    Date dueDate

    String toString() {
        "${name}"
    }

    static belongsTo = [enduser: EndUser ,project: Project]

    static constraints = {

        name()
        description()
        dueDate() 
    }
}

我的控制器类如下:

package projecttracker

class TaskController {
    def scaffold =true 

    def index() {
        redirect(action:list)
    }
}

但是,每当我调用Task控制器的index方法时,都会发生以下错误:

URI :     /ProjectTracker/task/index
Class:    groovy.lang.MissingPropertyException
Message:  No such property: list for class: projecttracker.TaskController Possible solutions: edit, flash, class
Around line 7 of grails-app\controllers\projecttracker\TaskController.groovy
4:  def scaffold =true 
5:
6:    def index() {
7:      redirect(action:list)
8:  }
9:}

有人可以告诉我,如何在这里定义列表方法?提前谢谢。

1 个答案:

答案 0 :(得分:0)

确保为方法名称使用字符串,并且scaffold变量必须是静态的,即

static scaffold = true

def index(){       重定向(动作:“名单”) }