将空数组作为查询参数添加

huangapple go评论68阅读模式
英文:

Add empty array as a query param

问题

我卡在这个问题上:
我需要创建这个网址

.../check?variables=[]&last_name=name&...

所以我正在使用com.ning.http.client.RequestBuilder来构建我的请求
我尝试过这样做,但由于某种原因它不起作用

RequestBuilder reqBuilder = new RequestBuilder()
                .setUrl(url+"/check")
                .setMethod("GET")
                .setHeader("Bauth-Token", token)
                .addQueryParam("variables","")
                .setQueryParams(params);

请给予建议,我应该怎么做。

英文:

I'm stucked with this problem:
I need to create this url

.../check?variables=[]&last_name=name&...

So I'm using com.ning.http.client.RequestBuilder for building me request
I tried doing that way, but it's doesn't work for some reason

RequestBuilder reqBuilder = new RequestBuilder()
                .setUrl(url+"/check")
                .setMethod("GET")
                .setHeader("Bauth-Token", token)
                .addQueryParam("variables","")
                .setQueryParams(params);

Pls, give an advice, what I should do.

答案1

得分: 2

如果您希望 variables 的值为 [],为什么要将其设置为空字符串?

英文:

If you want variables to have the value [], why do you set it to an empty string?

huangapple
  • 本文由 发表于 2020年10月21日 21:12:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/64464306.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定