2

它向我抛出了第 3 行的异常。问题是我只有以下几行:

package controllers

import play.api._
import play.api.mvc._
import views._
import models._

object Application extends Controller {

  def index = Ok(views.html.index("grrr", "blabla"))

}

编辑:index.scala.html

@import helper._

@main("Todo") {

    <h1>Hello World</h1>

}

我在 windows xp 上使用 play 2.2.0 (with sbt)

4

2 回答 2

6

I think that problem is with yours line separator in IDE. I once change LF(Linux) to CR(Mac)(by mistake, not knowing that this has an impact on compilation) and struggle with the same problem. After changing to default sperator everything back to normal.

于 2013-09-28T20:02:28.843 回答
2

Play 中的第一行!模板是为签名定义保留的。Welcome当您创建新的 Play 应用程序时,屏幕中也会提到这一点。

除了为什么要导入的问题之外helper._,我会执行以下操作:

  1. 使第一行为空,或者至少没有导入语句。
  2. play clean
  3. 在此之后它应该可以工作,我希望:-)

更多的信息:

EDIT: 2013.09.24 at 22:15

You are passing two arguments to your view template (views.html.index("grrr", "blabla")), (views are compiled to functions). So in your function (`index view') the first line SHOULD define the function signature (arguments). I think that you should write your template as:

@(firstString : String, secondString : String)

@import helper._

@main("Todo") {

    <h1>Hello World</h1>

}
于 2013-09-24T15:51:52.670 回答