这是我的web.xml
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>Upload</servlet-name>
<servlet-class>Upload</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Upload</servlet-name>
<url-pattern>/upload</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>SystemServiceServlet</servlet-name>
<servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value>com.company.game.GameApi</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>SystemServiceServlet</servlet-name>
<url-pattern>/_ah/spi/*</url-pattern>
</servlet-mapping>
</web-app>
我有一个Google Cloud Endpoint api,GameApi,除了加载花费太长时间的blob之外,它一直运行正常。所以我决定使用Upload
servlet on the google website to upload my blobs from user。我基本上将blob文件的xml代码添加到端点api的现有xml代码中,从而生成上面显示的xml。但是从不调用Upload servlet。我在localhost上测试,我可以在_BlobUploadSession_
表中看到前端(即android应用程序)已成功将图像发送到具有正确回调URL的blobstore。我知道servlet没有被调用,因为我在入口处有一个println语句。
我是否需要更改web.xml
?我是否允许将端点与servlet结合起来,就像我在web.xml
中一样?
答案 0 :(得分:1)
<servlet>
<display-name>Remote API Servlet</display-name>
<servlet-name>RemoteApiServlet</servlet-name>
<servlet-class>com.google.apphosting.utils.remoteapi.RemoteApiServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RemoteApiServlet</servlet-name>
<url-pattern>/remote_api</url-pattern>
</servlet-mapping>
答案 1 :(得分:0)
虽然我的Android Studio Cloud Endpoints gradle已成功同步,但在上传到GAE时,以下格式(您正在使用)导致错误和上传失败:
<servlet>
<servlet-name>Upload</servlet-name>
<servlet-class>Upload</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Upload</servlet-name>
<url-pattern>/upload</url-pattern>
</servlet-mapping>
我需要做的是列出完整的servlet类路径。在你的情况下:
<servlet>
<servlet-name>Upload</servlet-name>
<servlet-class>com.company.game.Upload</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Upload</servlet-name>
<url-pattern>/upload</url-pattern>
</servlet-mapping>
希望这有助于某人。