该字符串属性的值是否太长。它不能超过500个字符 [英] The string property has a value that is too long. It cannot exceed 500 characters

查看:1587
本文介绍了该字符串属性的值是否太长。它不能超过500个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是试图长字符串参数发送到端点法。其中一个PARAMS的是列表与LT;弦乐> ,包含大量的值,它是这样的:

I just tried to send a long String param to the endpoint method. One of the params is List<String>, that contains a large number of values, which look like this:

105969550886996847196,109334384788152421649,109172191656045871108,... and more

该方法本身是很简单的:

The method itself is very simple:

@ApiMethod(name = "getFullObjects")
public MyObject getFullObjects(List<String> ids) {
    //body not relevant
}

它抛出这个:

Error Code: 400
Reason: badRequest
Message: java.lang.IllegalArgumentException: The string property ids has a value that is too long. It cannot exceed 500 characters.

难道我真的不能在一个参数传递超过500个字符?这将是可怕的...:/

Do I really can't pass more than 500 characters in one param? That would be awful... :/

有没有办法超过这个限制或传递的数据有一些其他的方式?

Is there a way to exceed this limit or pass this data some other way?

注意:

这端点方法colaborates与Android应用程序!

This endpoint method colaborates with Android app!

注2:

如果有真的,真的是500个字符端点参数,wchich我不能为任何GAE文档中找到,不知道怎么有实体的名单差强人意的限制......他们中有些人肯定拿比500个字符的序列化字符串后。

If there realy, really is the limitation of 500 characters for endpoint param, wchich I can't find in any documentation for GAE, just wondering how there are list of Entities passable... some of them would sure take more than 500 chars after serialization to string.

推荐答案

我想我找到了最好的解决方案成为可能。

I think I found the best solution possible.

但首先...

由于谷歌App Engine开发小组由Google员工放弃,搬到这里我officialy发布它作为一个错误。这是一个ridicolous限制,只惹恼认真开发商和我不得不绕过它。 请删除无证limiation的端点方法参数500个字符!

Since Google App Engine developers group was abandoned by googlers and moved here I officialy post it as a bug. This is a ridicolous limitation, that only annoys serious developers and I just had to bypass it. Please remove undocumented limiation of 500 chars in endpoint method param!

然后向溶液...

我已经决定要定义一个新的servlet将处理这个,而不是终点的方法。在这里,它是:

I've decided to define a a new servlet that would handle this instead of endpoint method. Here it is:

public class LongParamTestServlet extends HttpServlet {


    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String paramsString = req.getParameter("params");
        resp.getWriter().write("string length: " + paramsString.length());
    }
}

然后我做出这个servlet的请求有一些很长的参数...

Then I made a request to this servlet with some very long param...

而现在的回应...

string length: 1664

中提琴!刚过长度1664我的谷歌应用程序引擎的后端参数我只是序列它作为一个JSON和响应返回一个JSON了。不一样舒适作为终点的方法,但它的工作原理。

Viola! Just passed to my Google App Engine backend param of length 1664. I'll just serialize it as a json, and return a json in response too. Not as comfortable as an endpoint method but it works.

这篇关于该字符串属性的值是否太长。它不能超过500个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆