【问题标题】:Trying to populate list using scala and lift尝试使用 scala 填充列表并提升
【发布时间】:2017-05-08 12:38:37
【问题描述】:

我正在尝试使用 scala 和 lift 填充列表,但我得到了一个找不到类的异常。代码直接来自“Lift in Action”一书。

这是包含虚拟数据的 sn-p 代码,应该显示它。

import scala.xml.NodeSeq
import net.liftweb.util.Helpers._
object Library {
  case class Book(name: String)
  case class Author(name: String, books: List[Book])
  val books = List(
    Author("JK Rowling", List(
      Book("Harry Potter and the Deathly Hallows"),
      Book("Harry Potter and the Goblet of Fire"))
    ),
    Author("Joshua Suereth", List(
      Book("Scala in Depth"))
    )
) }
class Authors {
def list =
    "ul" #> Library.books.map { author =>
      ".name" #> author.name &
      ".books" #> ("li *" #> author.books.map(_.name))
   }
}

这里是 HTML 代码,应该显示作者及其书籍的列表。

<ul lift="authors.list">
  <li><span class="name">Author</span>
    <ul class="books">
      <li>Book title</li>
    </ul>
  </li>
</ul>

运行时出现此错误:

Error processing snippet: authors.list 
Reason: Class Not Found 

关于出了什么问题有什么想法吗?

【问题讨论】:

  • 您的 sn-p 位于哪个包中?除非另有配置,否则默认情况下会在 snippet 包中查找 sn-ps
  • 我实际上得到了这个工作。我已将代码嵌入到其他东西中进行测试,并使用了错误的查找路径。所以我想这可以关闭。

标签: scala lift


【解决方案1】:

作者需要一个大写的 A 来匹配对象名称。

必须

<ul lift="Authors.list"> ... </ul>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多