简体   繁体   中英

play framework (2.3) - Getting asset URL from controller

I'm using iText to generate a PDF file in a controller, but I need to insert an image from the public assets in the file using it's URL. Is there any way to get the asset URL from the controller?

Reverse routing works for assets just like for controllers. This should provide you with required information:

controllers.routes.Assets.at("images/unchecked.png").absoluteURL(request())

You can read more about it in the section Reverse routing for public assets of the documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM