java - Play Framework @routes.Assets.at Compilation Error -


i'm using play 2.4.0 , i've been trying follow tutorial main page: https://playframework.com/ play 2.3 , after solving couple of issues regarding changes in ebean orm version 2.3 2.4, i'm stuck following error:

compilation error  value @ not member of controllers.reverseassets 

my index.scala.html:

@(message: string)  @main("welcome 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> } 

and routes file:

# routes # file defines application routes (higher priority routes first) # ~~~~  # home page         /                    controllers.application.index()  post        /person              controllers.application.addperson()          /persons             controllers.application.getpersons()  # map static resources /public folder /assets url path         /assets/*file        controllers.assets.versioned(path="/public", file: asset) 

i have same example working ok play 2.3.9

and can't see different working public assets in docs 2.4.0: https://www.playframework.com/documentation/2.4.0/assets

so... appreciated.

alright, sum solution: play lets serve assets in 2 different ways. old fashioned , new fingerprinted method introduced sbt-web. in either case make sure use right call in view files:

fingerprinted assets

this recommended way serve assets in play. fingerprinted assets make use of aggressive caching strategy. can read more topic here: https://playframework.com/documentation/2.4.x/assets

routes config:

get     /assets/*file               controllers.assets.versioned(path="/public", file: asset) 

make sure type of file indicated asset

call in views:

@routes.assets.versioned("an_asset") 


old fashioned assets

this method used before introduction of sbt-web.

routes config:

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

call in views:

@routes.assets.at("an_asset") 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -