Play Framework @ routes.Assets.at编译错误 [英] Play Framework @routes.Assets.at Compilation Error

查看:176
本文介绍了Play Framework @ routes.Assets.at编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Play 2.4.0,我一直在尝试按照主页中的教程: https:// playframework.com/
适用于Play 2.3,在解决了有关Ebean ORM从版本2.3到2.4的更改的几个问题后,我遇到了以下错误:

I'm using Play 2.4.0 and I've been trying to follow the tutorial from the main page: https://playframework.com/ which is for Play 2.3 and after solving a couple of issues regarding changes in the Ebean ORM from version 2.3 to 2.4, I'm stuck with the following error:

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>
}

我的路线 file:

# 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

I have this same example working ok with Play 2.3.9

在2.4.0的文档中使用公共资产我看不出任何不同: https://www.playframework.com/documentation/2.4.0/Assets

And I can't see anything different about working with public assets in the docs for the 2.4.0: https://www.playframework.com/documentation/2.4.0/Assets

所以。 ..任何帮助将不胜感激。

So... any help would be appreciated.

推荐答案

好的,总结一下解决方案:Play可让您以两种不同的方式提供资产方法。用sbt-web引入的老式和新的指纹方法。在任何一种情况下,请确保在视图文件中使用正确的调用:

Alright, to sum up the solution: Play lets you serve your assets in two different ways. The old fashioned and the new fingerprinted method introduced with sbt-web. In either case make sure you use right call in your view files:

这是推荐的在游戏中提供资产的方式。指纹资产利用积极的缓存策略。您可以在此处详细了解此主题: https://playframework.com/documentation/2.4.x/Assets

This is the recommended way to serve assets in play. Fingerprinted assets make use of an aggressive caching strategy. You can read more about this topic here: https://playframework.com/documentation/2.4.x/Assets

路线配置:

GET     /assets/*file               controllers.Assets.versioned(path="/public", file: Asset)

确保文件的类型表示为资产

在观看中调用:

@routes.Assets.versioned("an_asset")


这基本上是在引入sbt-web之前使用的方法。

This is basically the method used before the introduction of sbt-web.

routes config:

GET     /assets/*file               controllers.Assets.at(path="/public", file)

致电观看次数

@routes.Assets.at("an_asset")

这篇关于Play Framework @ routes.Assets.at编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆