【问题标题】:Can I return a generic in Google Cloud End Point我可以在 Google Cloud End Point 中返回泛型吗
【发布时间】:2013-04-11 09:43:40
【问题描述】:

当我返回一个泛型时,端点 api 文件似乎消失了。示例代码已粘贴。

@ApiMethod
public RestResponse<Container> testGeneric() {
    Container container = new Container();

    container.testLong =  (long)4345;
    container.testDate = new Date();
    container.testString = "sathya";
    container.testDouble = 123.98;
    container.testInt = 123;

    RestResponse<Container> response = new RestResponse<Container>();
    response.t = container;

    return response;        
}

这是端点中的错误吗?根本不允许这样的事情吗?

问候, 沙迪亚

【问题讨论】:

    标签: google-app-engine google-cloud-endpoints


    【解决方案1】:

    我不认为这是一个错误,但它只是不受支持,就像你不能从你的端点返回 String...

    为了检查问题所在,如果您使用的是 Google Plugin for Eclipse,您可以查看Window -&gt; Show View -&gt; Error Log 下的错误日志以获取更多信息。

    【讨论】:

    • Google 文档说返回类型“必须是 POJO,...”而没有关于泛型,所以我会说这是一个错误。
    猜你喜欢
    • 2021-10-04
    • 2011-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多