播放框架Form.form找不到符号

时间:2013-09-25 15:03:49

标签: java playframework

我正在阅读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;
}
}

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

谢谢!

2 个答案:

答案 0 :(得分:1)

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

import static play.data.Form.*;

答案 1 :(得分:0)

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