[英]scalate scalatra NoValueSetException with jade
I'm using Scalatra with Scalate and Jade. 我正在将Scalatra与Scalate和Jade一起使用。 When ever I try to apply a template that takes values the values are not being applied to the template and I'm getting a NoValueSetException... Here is the code I have: 每当我尝试应用带有值的模板时,值都不会应用于模板,并且会出现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"
and the exception: 和例外:
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)
Try cleaning the temp/generated files via the following command 尝试通过以下命令清除临时文件/生成的文件
sbt clean clean-files
Then start the Jetty server. 然后启动Jetty服务器。 It might help. 这可能会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.