//获取request的输入流,并设置格式为UTF-8
BufferedReader streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
//将输入流数据放入StringBuilder
StringBuilder resultSB = new StringBuilder();
String inputStr = null;
while ((inputStr = streamReader.readLine()) != null) {
resultSB.append(inputStr);
}
//将StringBuilder转换为JSONObject
JSONObject resultObj = JSONObject.parseObject(resultSB.toString());
接收并解析request中的字节流数据,转换为JSON格式
最新推荐文章于 2024-07-06 15:41:30 发布