发挥框架形式问题

时间:2013-01-10 09:12:19

标签: java playframework playframework-2.1

我在http://www.playframework.org/documentation/2.0.4/JavaTodoList上做的例子 但我有形式的问题。 如果您查看“任务表单”部分,您会看到我被要求添加 static Form taskForm = form(Task.class); 到应用程序控制器。

我得到的问题是“方法表单(类)未定义类型Application”

我正在运行play-2.1-RC1而不是play-2.0.4(play-2.0.4是示例中谈到的那个)

这是我得到的编译错误

[info] Compiling 4 Scala sources and 2 Java sources to /Users/johnnybekkestad/Documents/workspace/play/todolist/target/scala-2.10/classes...
[error] /Users/johnnybekkestad/Documents/workspace/play/todolist/app/controllers/Application.java:12: error: cannot find symbol
[error]     static Form<Task> taskForm = form(Task.class);
[error]                                  ^
[error]   symbol:   method form(Class<Task>)
[error]   location: class Application
[error] 1 error
[error] (compile:compile) javac returned nonzero exit code
[error] application -

! @6d1acongn - Internal server error, for (GET) [/] ->

sbt.PlayExceptions$CompilationException: Compilation error[error: cannot find symbol]
    at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15$$anonfun$apply$16.apply(PlayReloader.scala:322) ~[na:na]
    at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15$$anonfun$apply$16.apply(PlayReloader.scala:322) ~[na:na]
    at scala.Option.map(Option.scala:133) ~[scala-library.jar:na]
    at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15.apply(PlayReloader.scala:322) ~[na:na]
    at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15.apply(PlayReloader.scala:319) ~[na:na]
    at scala.Option.map(Option.scala:133) ~[scala-library.jar:na]

1 个答案:

答案 0 :(得分:18)

更改行:

form(Task.class);

有:

Form.form(Task.class);

当然,您必须添加:

import views.html.*;