【问题标题】:incorrect response object returned using restygwt使用 restygwt 返回的响应对象不正确
【发布时间】:2016-09-15 06:36:12
【问题描述】:

我正在使用 restygwt 制作客户端-服务器应用程序。我已经编写了我的方法并制作了一个 servlet。

    @GET
    @Path("/get/getpoints/{projectId}")
    @Produces(MediaType.APPLICATION_JSON)
    void getAZPoints(@PathParam("projectId") BigInteger projectID,
        MethodCallback <Map<String, String>> responseWithName);

当使用Map&lt;String, String&gt; 类型的响应时,我从客户端的服务器收到不正确的响应。 Servlet 返回数据如下:

["1":"New Pole","2":"New Manhole","3":"New Container 2","4":"New Building#11"] 

但是当它收到时,我的回复只包含 2 个条目。

如果我将类型更改为List&lt;String&gt;

    @GET
    @Path("/get/getpoints/{projectId}")
    @Produces(MediaType.APPLICATION_JSON)
    void getAZPoints(@PathParam("projectId") BigInteger projectID,
        MethodCallback <List<String>> responseWithName);

我的响应和servlet返回数据一样。

你能帮我解决这个问题吗?

【问题讨论】:

    标签: java json rest servlets gwt


    【解决方案1】:

    我发现这是一个众所周知的问题 - https://github.com/resty-gwt/resty-gwt/issues/119。发生这种情况是因为我的字符串(在我的示例中实际上是一个数字字符串,如“123”等)像数字一样发送并以错误的方式解码。作为一种解决方案,我将我的大整数作为带有一些文本字符的字符串发送,并在客户端对其进行解码。现在可以正常使用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-18
      • 2016-10-13
      • 1970-01-01
      • 2018-05-10
      相关资源
      最近更新 更多