2

我正在使用 CDN(亚马逊云端),我正在尝试将播放配置为与 CDN 一起使用

GET    xxxxxxxxx.cloudfront.net/*file               controllers.Assets.at(path="",file)

这种方法的问题是我的图片网址看起来像这样

http://localhost:9000/xxxxxxxxxxxxxxx.cloudfront.net/images/Ascalon_Wall_Ruins.jpg

我需要删除http://localhost:9000/

任何想法我怎么能做到这一点?

4

2 回答 2

3

我这样解决了我的问题:

package Config;

public class CDN {
    private final static String url = "http://yourcdnurl.net/;

    public static String createUrl(String s) {
        return url + s;
    }
}

用法:

<link rel="stylesheet" media="screen" href= "@Config.CDN.createUrl("stylesheets/bootstrap.css")">
于 2012-08-18T15:46:29.750 回答
3

您不需要使用 Playrouter来构建外部链接,而是只需在其前面加上域,即。如果您将路径存储在模型images/Ascalon_Wall_Ruins.jpg中的file字段中,则可以直接将其放入模板中:

@for(item <- itemsList){
    <img src="http://domain.tld/@item.file" />
}

当然你也可以在你的模型类中创建额外的方法来传递ready-to-use路径。

于 2012-08-18T15:09:07.923 回答