Route to static file in Play! 2.0

后端 未结 9 1745
甜味超标
甜味超标 2021-01-30 14:05

I\'m trying to make a route to a specific static file but everything I\'m trying ends with an error.

I\'ve made 3 different attempts:

1.

GET /fil         


        
9条回答
  •  执笔经年
    2021-01-30 14:09

    I have the exact same issue. I followed the advice from @Jamil and managed to get this working for the static file (in my case a favicon) and managed to get the templates to compile but get a new error at runtime when trying to use the view. Relevant code below,

    Change to the route (this route now resolves correctly)

    GET     /favicon.ico                controllers.Assets.at(path="/public/images", file="favicon.png")
    

    Change to the view (compiles)

    
    

    New error (only at runtime)

    [MatchError: (stylesheets/,main.css) (of class scala.Tuple2)]
    
    // @LINE:29
    // @LINE:28
    def at(path:String, file:String) = {
       (path, file) match {
    // @LINE:28
    case (path, file) if path == "/public" => Call("GET", "/assets/" + implicitly[PathBindable[String]].unbind("file", file))
    

    I know this isnt an answer but perhaps it will allow someone to pipe up with one.

提交回复
热议问题