我的播放视图看起来像这样
@(productInfo: model.ProductInfo)(price: String)
@main("Product Info") {
<h1>@productInfo.name</h1>
<h1>Product Price: @price</h1>
<h1>Product Attributes</h1>
<div>
@productInfo.attributes.map{(key, val) => <div>Product key: @key</div>}
</div>
}
然而在'sbt compile'上我收到以下错误
[error] /Users/asattar/Dev/work/StoreApp/app/views/productInfo.scala.html:9: illegal start of simple expression
[error] @productInfo.attributes.map{(key, val) => <div>Product key: @key</div>}
[error] ^
[error] /Users/asattar/Dev/work/StoreApp/app/views/productInfo.scala.html:11: ')' expected but '}' found.
productInfo.attributes是Map [String,String]
我是个小伙子,不知道这里发生了什么。帮助将不胜感激。谢谢!
答案 0 :(得分:2)
val
是有效的Scala关键字。您不能将Scala关键字用于变量名称。
使用v
或value
或foo
等