play framework(2.3) - 从控制器获取资产URL [英] play framework (2.3) - Getting asset URL from controller
本文介绍了play framework(2.3) - 从控制器获取资产URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用iText在控制器中生成PDF文件,但我需要使用它的URL从文件中的公共资源插入图像。
有没有办法从控制器获取资产URL?
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())
您可以在公共反向路由部分中详细了解它资源 文档。
这篇关于play framework(2.3) - 从控制器获取资产URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文