Play Framework @routes.Assets.at Compilation Error

前端 未结 1 1388
别跟我提以往
别跟我提以往 2021-02-01 02:32

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 rega

相关标签:
1条回答
  • 2021-02-01 03:06

    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:

    Fingerprinted 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

    routes config:

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

    Make sure the type of file is indicated as Asset

    call in views:

    @routes.Assets.versioned("an_asset")
    


    Old fashioned assets

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

    routes config:

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

    call in views:

    @routes.Assets.at("an_asset")
    
    0 讨论(0)
提交回复
热议问题