我正在使用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)
答案 0 :(得分:0)
尝试通过以下命令清除临时/生成的文件
sbt clean clean-files
然后启动Jetty服务器。这可能有所帮助。