scala - 为方法 Apply 提供太多参数

标签 scala playframework playframework-2.0

我正在制作 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/

相关文章:

mysql - 需要将 PreparedStatement 与 Anorm scala 结合使用的示例

scala - Play : Run tests with custom GuiceApplicationLoader

scala - 如何通过组合输入元组来组成元组一元函数

scala - 在 Spark 批处理作业中读取 Kafka 主题

playframework - Play Framework 2 : Eclipse cant detect jBCrypt as project dependency

java - 为什么一些 Java 代码再次导入相同的包?

javascript - 使用 "use strict"的函数形式。 angularjs 身份验证(使用 scala、play 框架)

java - 如何在 Play! 的静态方法中使用 play.cache.CacheApi框架 2.4.2

scala - Play 框架中 Futures 上的 Cache.getOrElse

java - Play 无标签的框架输入