我试图用javascriptRoutes
在播放2(斯卡拉),我得到一个错误(见下文)。 下面是我做的:
添加javascriptRoutes
方法Application
控制器
def javascriptRoutes = Action { implicit request =>
import routes.javascript._
Ok(Routes.javascriptRouter("jsRoutes")(Orders.searchProducts))
.as("text/javascript")
}
添加路由, routes
文件
GET /assets/javascripts/routes controllers.Application.javascriptRoutes
添加<script>
进口main.scala.html
<head>
...
<script type="text/javascript" src="@routes.Application.javascriptRoutes"></script>
...
</head>
有了这些变化的地方我得到的JavaScript控制台以下错误:
GET http://localhost:9000/assets/javascripts/routes 404 (Not Found)
Uncaught ReferenceError: jsRoutes is not defined
我在想什么?