Play Framework: How to get the absolute path of an

2019-07-14 07:56发布

问题:

My Play application automatically generates some HTML emails, which of course reference some images on the server. Since HTML emails require full URLs to get the images on the client side, I've defined the base URL in my application.conf and then build the full path in my view template. That said, is there a way to get the complete URL of the public/images directory so that I no longer need an additional configuration?

Thanks.

回答1:

AFAIK, you can get the full URL on an asset using reverse routing:

routes.Assets.at("images/anImage.png").absoluteURL()