我正在使用CDN (amazon cloudfront),并且正在尝试配置play以使用CDN
GET xxxxxxxxx.cloudfront.net/*file controllers.Assets.at(path="",file)这种方法的问题是我的图像url看起来像这样。
http://localhost:9000/xxxxxxxxxxxxxxx.cloudfront.net/images/Ascalon_Wall_Ruins.jpg我需要删除http://localhost:9000/
你知道我该怎么做吗?
发布于 2012-08-18 23:09:08
你不需要使用Play的域名来建立外部链接,相反,你只需要在它前面加上router,即。如果您在模型的file字段中以images/Ascalon_Wall_Ruins.jpg的形式存储路径,则可以直接将其放入模板中:
@for(item <- itemsList){
<img src="http://domain.tld/@item.file" />
}当然,您也可以在模型的类中创建额外的方法来提供ready-to-use路径。
发布于 2012-08-18 23:46:30
我这样解决了我的问题:
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")">https://stackoverflow.com/questions/12019515
复制相似问题