Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google app engine 从未命名的Google云端点访问请求参数_Google App Engine_Rest_Servlets_Cloud_Endpoints - Fatal编程技术网

Google app engine 从未命名的Google云端点访问请求参数

Google app engine 从未命名的Google云端点访问请求参数,google-app-engine,rest,servlets,cloud,endpoints,Google App Engine,Rest,Servlets,Cloud,Endpoints,我正在使用Google云端点,并且有一个GET方法。我正在使用的前端库添加了按以下约定命名的请求参数: 可排序的{INT} 可移植的 可移植的 可移植的2 可移植的3 这些参数的数量始终会因使用的列数而异。还有许多其他命名参数也遵循相同的约定 由于这些参数是动态命名和提供的,因此为每个参数创建@Nullable@命名参数是不可行的。我想我应该做的是注入HttpServletRequest并从请求中获取参数,但看起来Cloud Endpoints API可能在到达我的方法之前就已经去掉了这些参数

我正在使用Google云端点,并且有一个GET方法。我正在使用的前端库添加了按以下约定命名的请求参数:

可排序的{INT}

可移植的 可移植的 可移植的2 可移植的3

这些参数的数量始终会因使用的列数而异。还有许多其他命名参数也遵循相同的约定

由于这些参数是动态命名和提供的,因此为每个参数创建@Nullable@命名参数是不可行的。我想我应该做的是注入HttpServletRequest并从请求中获取参数,但看起来Cloud Endpoints API可能在到达我的方法之前就已经去掉了这些参数

请求URI:

 _ah/api/myapp/v1/list?bSortable_0=true&bSortable_1=true&bSortable_2=true&bSortable_3=true
_ah/api/myapp/v1/list?filter=bSortable_0::true||bSortable_1::true||bSortable_2::true||bSortable_3::true
Api方法:

@ApiMethod
public getList(HttpServletRequest request) {
  int len = request.getParameterMap().size(); // len == 0
}
我怀疑这可能是故意的。除了创建任意数量的可能超过50分的命名参数外,还有什么建议吗

编辑:事实上,命名参数甚至不是一个解决办法,我希望能够像地图一样访问这些参数

map.get("bSortable_" + myInt)
request.getParameter("bSortable_" + myInt)

我认为在这种情况下,云端点是不可能的。 在您的位置上,我会使用一种(糟糕的)解决方法,比如使用分隔符构建单个命名参数。例如:

请求URI:

 _ah/api/myapp/v1/list?bSortable_0=true&bSortable_1=true&bSortable_2=true&bSortable_3=true
_ah/api/myapp/v1/list?filter=bSortable_0::true||bSortable_1::true||bSortable_2::true||bSortable_3::true
方法:

@ApiMethod
public getList({@Named} filter) {
  String[] params = filter.split("||");
}

Google Cloud Endpoints是一个非常特殊的REST框架…

我想这就是我想要的确认。对于解决方案的创新想法,我正在使用的库需要进行修改才能实现这一点。因此,对于这个特定场景,我将坚持使用一个简单的旧servlet。谢谢你的回复,很高兴接受答案。