我的连接对象代码是 -
OutputStream os = conn.getOutputStream();
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(os, UTF));
writer.write(getQuery(params));
writer.flush();
writer.close();
os.close();
和我的getQuery(params)是 -
public String getQuery(List<NameValuePair> params) throws UnsupportedEncodingException
{
StringBuilder result = new StringBuilder();
boolean first = true;
for (NameValuePair pair : params)
{
if (first)
first = false;
else
result.append("&");
result.append(URLEncoder.encode(pair.getName(), "UTF-8"));
result.append("=");
result.append(URLEncoder.encode(pair.getValue(), "UTF-8"));
}
return result.toString();
}
答案 0 :(得分:-2)
这是一个容易出错的错误做法,请尝试使用Retrofit库。