0

ビュー パッケージにシンプルな index.scala.html を記述します。

@import controllers.Application.AuthenticatedRequest

@(posts: Iterator[Post], message: String = "" )(implicit request: AuthenticatedRequest)
.....

エラーは次のとおりです。

[error] F:\Kepler\blog\app\views\posts\index.scala.html:2: ')' expected but '='
found.
[error] @(posts: Iterator[Post], message:String = "")(implicit request: Authenti
catedRequest)
[error]                                         ^

メッセージのデフォルト値を「」に設定するのが正しい方法だと思います。ここで「=」ではなく「)」が期待される理由は誰でも知っています

4

2 に答える 2

1

@Max が述べたように、最初の行にはパラメーターを含める必要があります。インポートせずにパラメーターの型が認識されない場合は、型名を完全に修飾する必要があります。この場合、次のようになります。

@(posts: Iterator[Post], message: String = "" )(implicit request: controller.Application.AuthenticatedRequest)

F:\Kepler\blog\project\Build.scalaまたは、テンプレート パラメーター リストで型を頻繁に使用する予定がある場合は、次のように、ファイルに追加のインポートを指定できます。

val main = play.Project(appName, appVersion, appDependencies).settings(
  ..., // your settings here like resolvers, etc.
  templatesImport += "controllers.Application._",
  templatesImport += "models._", //etc.
  ... // further settings or the end of the list - remember: last item without coma
)

次に、パラメーター リストに表示されるインポートを使用してテンプレートが生成されます。

于 2013-09-16T19:40:47.973 に答える