档案:Controllers -> Product.scala
object Products extends Controller {
def list = Action { implicit request =>
val products = Product.findAll
Ok(views.html.products.list(products))
投掷错误
太多了 方法的参数适用:()play.api.templates.HtmlFormat.Appendable 在对象列表中
档案:views->products->list.scala.html
@(products: List[Product])(implicit lang: Lang)
@main(Messages("application.name")) {
<dl class="products">
档案:model->Product.scala
case class Product( // MODEL CLASS
ean: Long, name: String, description: String)
object Product { // DAO :
var products = Set(
Product(5010255079763L, "Paperclips Large",
"Large Plain Pack of 1000"),
Product(5018206244666L, "Giant Paperclips",
"Giant Plain 51mm 100 pack"),
Product(5018306332812L, "Paperclip Giant Plain",
"Giant Plain Pack of 10000"),
Product(5018306312913L, "No Tear Paper Clip",
"No Tear Extra Large Pack of 1000"),
Product(5018206244611L, "Zebra Paperclips",
"Zebra Length 28mm Assorted 150 Pack")
)
def findAll = products.toList.sortBy(_.ean)
档案:routes
GET /products controllers.Products.list
太多参数的抛出错误