Http Post传输的内容,首字母不能使用"["符号
仙茅 2015-06-18 07:18:09 String content="[{company_id: \"100010\",product_id: 1,money: 1000000},{company_id: \"100011\",product_id: 1,money: 2000000}]";
for (int i = 0; i < content.getBytes().length; i++) {
System.out.println((char)content.getBytes()[i]);
}
OutputStream os=conn.getOutputStream();
os.write(content.getBytes(Charset.forName("UTF-8")));
// DataOutputStream dos=new DataOutputStream(conn.getOutputStream());
// System.out.println(content);
// dos.writeBytes(content);
conn.connect();
以上是我的代码,我想通过post这种方式把数据传给服务器,然而服务器接收到的只有这一部份:{company_id: \"100010\",product_id: 1,money: 1000000},{company_id: \"100011\",product_id: 1,money: 2000000}] 从上面代码中看出,我使用了多种传输方式,都是一样的。如果在"["前面随便加一个字母,这个问题解决,但是加的字母被丢掉了。一直没明白是为什么?