通过request获得请求的json格式的参数

public static JSONObject getjsonParamByRequest(HttpServletRequest request) throws IOException {
BufferedReader streamReader = new BufferedReader( new InputStreamReader(request.getInputStream(), “UTF-8”));
StringBuilder responseStrBuilder = new StringBuilder();
String inputStr;
while ((inputStr = streamReader.readLine()) != null) {
responseStrBuilder.append(inputStr);
}
JSONObject jsonObject = JSONObject.parseObject(responseStrBuilder.toString());
return jsonObject;
}

你可能感兴趣的:(java,json格式请求)