How to serve static asset from controller action in Play Framework 2.3?
In my application, I need to serve a static file from a shared folder. And for some reason I have to do it with a Java controller action.
The first solution that came to my mind is to do something like:
public class Central extends Controller {
public static Result index() {
return Assets.at("/public", "central/index.html", false);
}
}
But the return type of the method Assets.at
isplay.api.mvc.Action<play.api.mvc.AnyContent>
Is there a way to convert it to a type play.mvc.Result
?
Or any other elegant way to execute a static file from a Java controller action?
+3
source to share