Playframework 2.0 播放框架-使用参数从另一个视图调用视图

Playframework 2.0 播放框架-使用参数从另一个视图调用视图,playframework-2.0,scala-2.10,twirl,Playframework 2.0,Scala 2.10,Twirl,我试图从中的视图调用主布局,但出现错误: [error] C:\Users\Marco\Documents\Devel\Java\DroversWeb\app\views\device\list.sca la.html:1: too many arguments for method apply: ()play.twirl.api.HtmlFormat.Appe ndable in object _layout [error] @views.html.shared._layout("User"

我试图从中的视图调用主布局,但出现错误:

 [error] C:\Users\Marco\Documents\Devel\Java\DroversWeb\app\views\device\list.sca
la.html:1: too many arguments for method apply: ()play.twirl.api.HtmlFormat.Appe
ndable in object _layout
[error] @views.html.shared._layout("User")
[error]                           ^
[error] C:\Users\Marco\Documents\Devel\Java\DroversWeb\app\views\shared\_layout.
scala.html:1: not found: value title
[error] ?@(title: String)
[error]    ^
[error] two errors found
[error] (compile:compile) Compilation failed
[error] Total time: 34 s, completed 29-gen-2015 16.27.59
以下是我尝试使用的代码: 控制器

列表视图

@views.html.shared.\u layoutUser

**_布局**

@(title: String)
<!DOCTYPE html>
<html lang="en">
<head>
....
</html>
**PLUGINS.SBT**

resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.7")
// web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.0.0")
代码怎么了

我也尝试过在_layout中使用content:Html,在list.scala.Html中使用Html代码,但编译器总是在@with not found:value title之后停止

如果我删除布局中的参数并使用@views.html.shared调用它。\u布局将正确编译。

OP写道:

从零开始,我现在有一个项目可以编译。。。一切都是一样的,为了找出问题,我一个接一个地复制了文件,但到目前为止没有问题。使用winmerge,我查看了文件夹,我可以看到,在target\scala-2.11\twirl….\shared_layout.template.html中,工作文件夹是:

/**/
object _layout extends BaseScalaTemplate[play.twirl.api.HtmlFormat.Appendable,Format[play.twirl.api.HtmlFormat.Appendable]](play.twirl.api.HtmlFormat) with play.twirl.api.Template1[String,play.twirl.api.HtmlFormat.Appendable] {

  /**/
  def apply/*1.2*/(title: String):play.twirl.api.HtmlFormat.Appendable = {
      _display_ {
/**/
object _layout extends BaseScalaTemplate[play.twirl.api.HtmlFormat.Appendable,Format[play.twirl.api.HtmlFormat.Appendable]](play.twirl.api.HtmlFormat) with play.twirl.api.Template0[play.twirl.api.HtmlFormat.Appendable] {

  /**/
  def apply():play.twirl.api.HtmlFormat.Appendable = {
      _display_ {
不起作用的是:

/**/
object _layout extends BaseScalaTemplate[play.twirl.api.HtmlFormat.Appendable,Format[play.twirl.api.HtmlFormat.Appendable]](play.twirl.api.HtmlFormat) with play.twirl.api.Template1[String,play.twirl.api.HtmlFormat.Appendable] {

  /**/
  def apply/*1.2*/(title: String):play.twirl.api.HtmlFormat.Appendable = {
      _display_ {
/**/
object _layout extends BaseScalaTemplate[play.twirl.api.HtmlFormat.Appendable,Format[play.twirl.api.HtmlFormat.Appendable]](play.twirl.api.HtmlFormat) with play.twirl.api.Template0[play.twirl.api.HtmlFormat.Appendable] {

  /**/
  def apply():play.twirl.api.HtmlFormat.Appendable = {
      _display_ {
我从原始项目中删除了_布局文件,从winmerge的角度复制了新的布局文件,现在它可以工作了


提供的代码工作得非常好。你是否尝试过清理并重新启动你的应用程序?是的,清理并重新启动,但没有成功。我已经用build.sbt和插件更新了这篇文章。sbt@views.html.shared._layouttitle=User Nothing也带有“title=”,在清理和编译相同的错误后:[错误]C:\Users\Marco\Documents\Devel\Java\DroversWeb\app\views\device\list.sca la.html:4:方法应用的参数太多:play.twirl.api.HtmlFormat.app在对象\u布局中[错误]@views.html.shared.\u layout title=User[error]^[error]C:\Users\Marco\Documents\Devel\Java\DroversWeb\app\views\shared\\u布局。scala.html:1:未找到:值标题[错误]?@title:String[错误]^[错误]发现两个错误[错误]编译:编译失败