沿边java google-enpoint api提供静态图像 [英] serve static image along side java google-enpoint api
问题描述
在Python中托管应用程序引擎的基本网站,我可以将所有图像文件放在一个静态目录中,比如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
我需要为Java谷歌端点后端做同样的事情。这将如何工作?我正在使用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中的所有文件都作为静态文件提供,但JSP和WEB-INF /中的文件除外。对于路径与静态文件相匹配的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-enpoint api提供静态图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!