我遵循下面的doc:Files来设置一个特定的资源文件位置,如下所示:
appengine-web.xml:
<resource-files>
<include path="/resources/*" />
</resource-files>现在,我需要在servlet上下文之外获取资源文件。所以,我试着用:
InputStream jsonResource = new FileInputStream("default/WEB-INF/resources/" + resourceName);这在本地开发服务器上运行很好,但是在生产中,我得到了一个IOException:
getResourceAsString: /base/data/home/apps/s~my-app-id/module2:multi-module-1.384597049666152751/default/WEB-INF/resources/query_url.json (No such file or directory)以下是我的GAE模块结构:
root-ear
- default
- src/main/webapp/WEB-INF
- resources
- src/main/java (some code)
- module2
- src/main/java (code that needs the resource)我看错文件了吗?资源文件的正确路径应该是什么?
其他详情:
发布于 2015-05-27 14:43:36
当前目录包含“WEB”和"_ah“文件夹。
下面是这个结构在WEB中的表现:
WEB-INF
- <all my files from my normal WEB-INF>
- resources <<< The folder I added under <resource-files>
- lib
- classes
- appengine-generated通过使用以下代码片段列出本地文件,我能够解决这个问题:
File curDir = new File("./WEB-INF");
File[] files = curDir.listFiles();
for (File file: files) {
logger.info(file.getName());
}https://stackoverflow.com/questions/30485435
复制相似问题