java httpsUrlconnection方式明明设置的是GET,但是接收就变成了POST
publicstaticJSONObjectsendHttpJson(StringaddUrl,Stringquery,StringrequestType){String...
public static JSONObject sendHttpJson(String addUrl,String query,String requestType)
{
StringBuffer sb = new StringBuffer();
int i =0;
try
{
//设置通信基本属性
URL url = new URL(addUrl);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod(requestType);
connection.setUseCaches(false);
connection.setInstanceFollowRedirects(true);
connection.setRequestProperty("Content-Type", "application/json; charset=utf-8");
connection.connect();
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
if(null !=query && query.trim().length()>0)
{
out.writeBytes("ResponseText:"+query);
}
out.flush();
out.close();
requestMethode设置的是GET,执行过connection.connect()后,就变成了POST,急求解! 展开
{
StringBuffer sb = new StringBuffer();
int i =0;
try
{
//设置通信基本属性
URL url = new URL(addUrl);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod(requestType);
connection.setUseCaches(false);
connection.setInstanceFollowRedirects(true);
connection.setRequestProperty("Content-Type", "application/json; charset=utf-8");
connection.connect();
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
if(null !=query && query.trim().length()>0)
{
out.writeBytes("ResponseText:"+query);
}
out.flush();
out.close();
requestMethode设置的是GET,执行过connection.connect()后,就变成了POST,急求解! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询