0

我将 Scalatra 与 Scalate 和 Jade 一起使用。当我尝试应用一个接受值的模板时,这些值并没有被应用到模板上,我得到一个 NoValueSetException ......这是我拥有的代码:

// --------- In PostsServlet ------------------
get("/:page") {
  /*
  val page:Int = params.getOrElse("page", "1").toInt
  val posts = PostCollection.page(page)
  */
  contentType="text/html"
  jade("/index.jade", "foo" -> "bar")
}


// ------------------ In index.jade ----------------------
-@ var foo : String

-attributes("title") = "Circuits Of Imagination"
-attributes("headline") = "Writings"

和例外:

The value for 'foo' was not set
org.fusesource.scalate.NoValueSetException: The value for 'foo' was not set
at org.fusesource.scalate.RenderContext$$anonfun$attribute$1.apply(RenderContext.scala:159)
at org.fusesource.scalate.RenderContext$$anonfun$attribute$1.apply(RenderContext.scala:159)
at org.fusesource.scalate.RenderContext$class.attributeOrElse(RenderContext.scala:167)
4

1 回答 1

0

尝试通过以下命令清理临时/生成的文件

sbt clean clean-files

然后启动 Jetty 服务器。它可能会有所帮助。

于 2016-06-04T11:09:05.453 回答