Java Apache Tapestry:META-INF/assets中资产的绝对路径
这里的解决方案帮助我在类路径(上下文)中获得资产的绝对路径 对于META-INF/assets(Tapestry 5.4存储资产的方式)中存储的资产,是否有相同的方法 具体来说,我想插入我在META-INF/assets文件夹中创建的.html(静态)文件的路径 目前我有:Java Apache Tapestry:META-INF/assets中资产的绝对路径,java,tapestry,Java,Tapestry,这里的解决方案帮助我在类路径(上下文)中获得资产的绝对路径 对于META-INF/assets(Tapestry 5.4存储资产的方式)中存储的资产,是否有相同的方法 具体来说,我想插入我在META-INF/assets文件夹中创建的.html(静态)文件的路径 目前我有: public String getMyHtml() { String clientURL = assetSource.getContextAsset("html/myhtml.html", locale).toCl
public String getMyHtml() {
String clientURL = assetSource.getContextAsset("html/myhtml.html", locale).toClientURL();
return clientURL;
}
tml文件有:
"{ url: '${getDeltaHtml()}' }"
如果
“myhtml.html”
文件位于类路径文件夹(WEB-INF)中,则此操作有效。如果它在META-INF/assets文件夹中,它就不起作用了,我想把它放在META-INF/assets文件夹中。您可以通过此操作获得存储在assets下的资产
首先,您必须注入以下内容
@Inject
private AssetSource assetSource;
@Inject
private ThreadLocale threadLocale;
之后,您可以使用以下内容获取资产
Asset asset = assetSource.getAsset(null, "classpath:META-INF/assets/myhtml.html", threadLocale.getLocale());