4

我正在阅读 Play Framework 教程。我收到此错误:

error: cannot find symbol

In /Users/hseritt/devel/todolist/app/controllers/Application.java at line 12.

import views.html.*;

public class Application extends Controller {

static Form<Task> taskForm = Form.form(Task.class); // ERROR IS HIGHLIGHTED AS Form.form 

public static Result index() {
    return redirect(routes.Application.tasks());
}

我的 Application.java 的完整代码:

package controllers;

import play.*;
import play.data.*;
import play.mvc.*;

import models.*;
import views.html.*;

public class Application extends Controller {

static Form<Task> taskForm = Form.form(Task.class);

public static Result index() {
        return redirect(routes.Application.tasks());
}

public static Result tasks() {
    return ok(
        views.html.index.render(Task.all(), taskForm)
    );
}

public static Result newTask() {
     return TODO;
}

public static Result deleteTask(Long id) {
    return TODO;
}
}

我想知道我是否错过了教程中的某些内容或将某些内容放在了错误的位置。

谢谢!

4

2 回答 2

1

我认为您应该导入以下内容:

import static play.data.Form.*;
于 2013-09-25T15:17:54.107 回答
0

根据 jnoob,只需将 import 更改为import play.data.Form,然后执行static Form<Task> taskForm = form(Task.class);,对我有用。

于 2014-10-22T07:52:39.327 回答