Scala 使用视图标记播放框架
这是我使用play framework的第一天,我正在使用视图模板 Application.scalaScala 使用视图标记播放框架,scala,playframework,Scala,Playframework,这是我使用play framework的第一天,我正在使用视图模板 Application.scala package controllers import play.api._ import play.api.mvc._ class Application extends Controller { val productMap = Map(1 -> "Keyboard", 2 -> "Mouse", 3 -> "Monitor") def listProduct
package controllers
import play.api._
import play.api.mvc._
class Application extends Controller {
val productMap = Map(1 -> "Keyboard", 2 -> "Mouse", 3 -> "Monitor")
def listProducts() = Action {
Ok(views.html.products(productMap.values.toSeq))
}
}
路线
GET /listProducts controllers.Application.listProducts
看法
视图标记
@(products: Seq[String])
<ul>
@for(product <- products) {
<li>@product</li>
}
</ul>
我觉得很好。可能是一些旧代码的旧编译
/activator clean
对我来说真的很好。可能是一些旧代码的旧编译/activator clean
你说得对。重命名并没有解决这个问题。我将该文件重新命名为productsIterator,它仍然有效。所以我想你的建议是停止激活剂,然后进行清洁,这确实解决了问题。太好了,只是想让你放心——我从来没有必要这么做,所以我确信这只是一个不幸的一次。它会在运行中重新编译(确切地说,下次运行相关代码时)。您是对的。重命名并没有解决这个问题。我将该文件重新命名为productsIterator,它仍然有效。所以我想你的建议是停止激活剂,然后进行清洁,这确实解决了问题。太好了,只是想让你放心——我从来没有必要这么做,所以我确信这只是一个不幸的一次。它会在运行中重新编译(确切地说,下次运行相关代码时)。您是对的。重命名并没有解决这个问题。我将该文件重新命名为productsIterator,它仍然有效。所以我想你的建议是停止激活剂,然后进行清洁,这确实解决了问题。太好了,只是想让你放心——我从来没有必要这么做,所以我确信这只是一个不幸的一次。它会动态地重新编译(确切地说,下次运行相关代码时)。
@(products: Seq[String])
<ul>
@for(product <- products) {
<li>@product</li>
}
</ul>
@6mgadekbj - Internal server error, for (GET) [/listProducts] ->
play.sbt.PlayExceptions$CompilationException: Compilation error[**too many arguments for method apply**: ()play.twirl.api.HtmlFormat.Appendable in class productsIterator]
at