问题
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
then to access my images, I simply do myid.appspot.com/img/pic.jpeg
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.
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
.
Ref storing static images in the blobstore
回答1:
According to the documentation, putting them in a folder other than WEB-INF
is all you have to do.
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.
A request to /img/famousActors/willSmith.jpeg
should work without additional configuration.
来源:https://stackoverflow.com/questions/16510724/serve-static-image-along-side-java-google-endpoint-api