8

这是我的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 的时间太长外,它一直运行良好。所以我决定使用Uploadgoogle 网站上的 servlet 从 user 上传我的 blob。我基本上将 blob 文件的 xml 代码添加到端点 api 的现有 xml 代码中,从而产生了上面显示的 xml。但是,Upload servlet 永远不会被调用。我正在本地主机上进行测试,我可以在_BlobUploadSession_表格中看到前端(即 android 应用程序)已使用正确的回调 url 成功地将图像发送到 blobstore。我知道没有调用 servlet,因为我在入口处有一个 println 语句。

我需要改变我的web.xml吗?我是否可以像在我的 中那样将端点与 servlet 结合起来web.xml

4

2 回答 2

1

查看https://cloud.google.com/developers/articles/how-to-build-mobile-app-with-app-engine-backend-tutorial

<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>
于 2014-05-19T09:49:55.143 回答
0

Although my Android Studio Cloud Endpoints gradle synced successfully, when uploading to GAE, the following format (which you are using) resulted in errors and unsuccessful upload:

<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>

What I needed to do was list out the full servlet-class path. In your case:

<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>

Hope this helps someone.

于 2016-04-07T15:42:39.563 回答