简体   繁体   English

播放框架(2.3)-从控制器获取资产URL

[英]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. 我正在使用iText在控制器中生成PDF文件,但是我需要使用其URL从文件中的公共资产插入图像。 Is there any way to get the asset URL from the controller? 有什么方法可以从控制器获取资产URL?

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 . 您可以在文档的 公共资产反向路由部分中了解有关此内容的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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