Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Apache Tapestry:META-INF/assets中资产的绝对路径_Java_Tapestry - Fatal编程技术网

Java Apache Tapestry:META-INF/assets中资产的绝对路径

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

这里的解决方案帮助我在类路径(上下文)中获得资产的绝对路径

对于META-INF/assets(Tapestry 5.4存储资产的方式)中存储的资产,是否有相同的方法

具体来说,我想插入我在META-INF/assets文件夹中创建的.html(静态)文件的路径

目前我有:

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());