Can anyone explain me this code?

前端 未结 2 1162
后悔当初
后悔当初 2021-01-06 21:02
import org.apache.http.message.BasicNameValuePair;

private String getServerData(String returnString) {               
InputStream is = null;

String result = \"\";
         


        
2条回答
  •  悲&欢浪女
    2021-01-06 21:47

    In the end you're doing a http POST request with the field "year" having the value "1970".

    Just like a webform posting that year would.

    A bit extra: The BasicNameValuePair looks quite aptly named: Its a very simple (basic) group of two things (pair) that serve as a formfield (name) and its contents (value).

    The httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); adds that combination of year and 1970 to the HttpPost object, but with encoding (so there are no 'illegal' things in there).

提交回复
热议问题