沿着java google-endpoint api提供静态图像 [英] serve static image along side java google-endpoint api
问题描述
在Python中托管app-engine上的基本网站,我可以将所有图像文件放在静态目录中,比如说img,然后在yaml文件中有
In Python to host a basic website on app-engine, I can put all my image files in a static directory, say img, and then in the yaml file have
- url: /img
static_dir: img
然后访问我的图片,我只需 myid.appspot.com/img/pic.jpeg
then to access my images, I simply do myid.appspot.com/img/pic.jpeg
我需要为Java google-endpoint后端做同样的事情。那会怎么样?我正在使用Google-eclipse-plugin。我想我需要编辑 web.xml
文件。但是我不确定我会把它放在那里。
I need to do the same thing for a Java google-endpoint backend. How would that work? I am using the Google-eclipse-plugin. I suppose I need to edit the web.xml
file. But I am not sure what I would put in there.
我的 / img
目录的结构是这样的它反过来包含许多目录,每个目录都包含图像。例如: /img/famousActors/willSmith.jpeg
。
The structure of my /img
directory is such that it in turn contains many directories, each with images in them. For example: /img/famousActors/willSmith.jpeg
.
推荐答案
根据文档,将它们放在 WEB-INF
以外的文件夹中即可。
According to the documentation, putting them in a folder other than WEB-INF
is all you have to do.
默认情况下,App Engine使WAR中的所有文件都可用作静态文件,但WEB-INF /中的JSP和文件除外。对路径与静态文件匹配的URL的任何请求都会直接向浏览器提供文件 - 即使路径也与servlet或过滤器映射匹配。
By default, App Engine makes all files in the WAR available as static files except JSPs and files in WEB-INF/. Any request for a URL whose path matches a static file serves the file directly to the browser—even if the path also matches a servlet or filter mapping.
对 /img/famousActors/willSmith.jpeg
的请求无需额外配置即可运行。
A request to /img/famousActors/willSmith.jpeg
should work without additional configuration.
这篇关于沿着java google-endpoint api提供静态图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!