在 http post/get 请求中发送空值的正确方法是什么。
重要提示:我的意思是为请求的特定参数发送NULL值,而不是空字符串或缺少字段。我认为以下选项不正确
http://test.com?param1=¶m2=bar //this is an empty string, not a null
http://test.com?param1=null¶m2=bar //this is a string with content "null"
http://test.com?param2=bar //param 1 is missing, not null
在 HTTP 中发送NULL是否有意义(并且是标准化的)还是我应该回退到以前的任何选项?在后一种情况下,标准方法是什么
在java中,当我使用:
URLEncoder.encode(null, "UTF-8")
它崩溃了 Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
使用OkHttp3 lib 并尝试添加空参数时,我也会崩溃
FormBody.Builder bodyBuilder = new FormBody.Builder();
bodyBuilder.add("param1",null)
小唯快跑啊
相关分类