当对方发送数据格式为json时,可使用下面代码
InputStream sin = new BufferedInputStream(request.getInputStream());
ByteArrayOutputStream sout = new ByteArrayOutputStream();
int len=0;
while((len=sin.read())!=-1)
{
sout.write(len);
}
byte[] temp = sout.toByteArray();
String postStr = new String(temp,"UTF-8");
最后这个postStr变量就是json字符串,然后按照要求转换就好了!