我正在制作 Pluralsight 的 Play2 和 Scala 教程。
我创建了一个默认项目并按如下方式配置:
Controller Application.scala
package controllers
import play.api._
import play.api.mvc._
class Application extends Controller {
def index = Action {
Ok(views.html.index("Hello, again, world!"))
}
}
查看index.scala.html
(@message: String)
<!doctype html>
<html>
<head>
<title>
Play 2 for Scala!
</title>
</head>
<body>
<h1>
@message
</h1>
</body>
</html>
我的路线文件中有以下路线:
GET / controllers.Application.index
我的问题是,当我尝试访问 http://localhost:9000/
时,我得到:
too many arguments for method apply: ()play.twirl.api.HtmlFormat.Appendable in class index
6class Application extends Controller {
7
8 def index = Action {
9 Ok(views.html.index("Hello, again, world!"))
10 }
11
12}
最佳答案
您在 View 中声明的参数列表是错误的
(@message: String)
应该是
@(message: String)
关于scala - 为方法 Apply 提供太多参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33880674/