我正在使用Play 2.4.0,一直试图按照主页上的教程进行操作:https://playframework.com/,该教程适用于Play 2.3。在解决了Ebean ORM从版本2.3到2.4的更改所导致的一些问题后,我现在被以下错误困扰:
Compilation error
value at is not a member of controllers.ReverseAssets
我的index.scala.html
:
@(message: String)
@main("Welcome to Play") {
<script type='text/javascript' src="@routes.Assets.at("javascripts/index.js")"></script>
<form action="@routes.Application.addPerson()" method="post">
<input type="text" name="name" />
<button>Add Person</button>
</form>
<ul id="persons">
</ul>
}
我的routes
文件如下:
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
GET / controllers.Application.index()
POST /person controllers.Application.addPerson()
GET /persons controllers.Application.getPersons()
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
我已经成功地使用Play 2.3.9实现了相同的示例。
在2.4.0的文档中,我没有看到任何有关使用公共资产的不同之处:https://www.playframework.com/documentation/2.4.0/Assets
因此...非常感谢任何帮助。
sbt clean
吗? - Romanactivator clean
和activator clean-files
,但是我得到了相同的错误。 - Daniel RomeroGET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
。请注意使用了versioned
而不是at
。也许这会有所帮助。如果没有,您可以发布您的路由配置可能更有帮助。 - Romanindex.scala.html
中将@routes.Assets.at("javascripts/index.js")
更改为@routes.Assets.versioned("javascripts/index.js")
。 - Roman