在 http post/get 請求中發(fā)送空值的正確方法是什么。重要提示:我的意思是為請求的特定參數(shù)發(fā)送NULL值,而不是空字符串或缺少字段。我認為以下選項不正確http://test.com?param1=¶m2=bar //this is an empty string, not a nullhttp://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 中發(fā)送NULL是否有意義(并且是標準化的)還是我應(yīng)該回退到以前的任何選項?在后一種情況下,標準方法是什么在java中,當我使用:URLEncoder.encode(null, "UTF-8")它崩潰了 Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference使用OkHttp3 lib 并嘗試添加空參數(shù)時,我也會崩潰FormBody.Builder bodyBuilder = new FormBody.Builder();bodyBuilder.add("param1",null)
如何在 HTTP POST/GET 中發(fā)送空參數(shù)
ibeautiful
2021-08-04 15:52:52