【问题标题】:scalate scalatra NoValueSetException with jadescalate scalatra NoValueSetException 与玉
【发布时间】:2013-08-21 16:06:57
【问题描述】:

我将 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)

【问题讨论】:

  • 您的代码看起来不错。当我尝试时它对我有用。你在某个地方有一个测试项目吗?你也可以这样做:val page = params.getAs[Int]("page").getOrElse(1)
  • 遗憾的是每个人都说它看起来不错。我没有代码了,因为我改用 Fink(基于 scalatra 的 CMS)。

标签: pug scalatra scalate


【解决方案1】:

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

sbt clean clean-files

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-11
    • 2011-08-04
    • 2011-08-20
    • 1970-01-01
    • 2013-02-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多