我刚刚从他们的网站下载了播放框架,并且正在学习本教程。
我注意到框架创建文件夹 app/controllers 和 app/views,但不是模型文件夹。我手动创建了它并将 Task.java 添加到它。当我到达标题为“渲染第一页”的部分并打开时,localhost:9000/tasks
我收到一个编译错误,上面写着package play.models does not exist
. 这是我的 Task.java 的样子:
package models;
import java.util.*;
public class Task {
public Long id;
@Required
public String label;
public static List<Task> all() {
return new ArrayList<Task>();
}
public static void create(Task task) {
}
public static void delete(Long id) {
}
}
这是application.java,产生编译错误的文件:
package controllers;
import play.*;
import play.mvc.*;
import views.html.*;
import play.data.*;
import play.models.*; // COMPILATION ERROR: "package play.models does not exist"!
public class Application extends Controller {
static Form<Task> taskForm = Form.form(Task.class);
public static Result index() {
//return ok(index.render("Your new application is ready."));
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;
}
}