import java.io.InputStream
import java.net.HttpURLConnection
import java.net.URL
import java.nio.charset.StandardCharsets
import java.util.ArrayList
import java.util.List
import org.apache.commons.codec.binary.Base64
import org.json.JSONArray
import org.json.JSONException
import org.json.JSONObject
把post的改成put试试HttpPost httpPost = new HttpPost("http xxx")
List <NameValuePair>nvps = new ArrayList <NameValuePair>()
nvps.add(new BasicNameValuePair("username", "vip"))
nvps.add(new BasicNameValuePair("password", "secret"))
httpPost.setEntity(new UrlEncodedFormEntity(nvps))
CloseableHttpResponse response2 = httpclient.execute(httpPost)
try {
System.out.println(response2.getStatusLine())
HttpEntity entity2 = response2.getEntity()
// do something useful with the response body
// and ensure it is fully consumed
EntityUtils.consume(entity2)
} finally {
response2.close()
}