7

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

我得到的问题是“应用程序类型的方法形式(类)未定义”

我正在运行 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]
4

1 回答 1

18

换行:

form(Task.class);

为了:

Form.form(Task.class);

当然,您必须添加:

import views.html.*; 
于 2013-01-10T13:45:48.757 回答