我通过POST发送String
:
connection = new URL(UrlAddress).openConnection();
connection.setDoOutput(true); // Triggers POST.
//urlConnection.setChunkedStreamingMode(0);
String charset = "UTF-8";
String param1 = "test";
String query = String.format("param1=%s",
URLEncoder.encode(param1, charset));
OutputStream output = connection.getOutputStream();
output.write(query.getBytes(charset));
inputStream = connection.getInputStream();
我可以通过一个POST操作发送两个参数,例如String query = String.format("param1=%s¶m2=%s", ...
吗?我需要在文本类型参数之后将字节序列参数(位图图片)附加到POST,我该怎么写呢?