注意:此时后台方法不能用 @RequestBody注解
方法:
public String getJsonStringFromRequest(HttpServletRequest request) throws IOException { StringBuffer sb = new StringBuffer() ; InputStream is = request.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String s = "" ; while((s=br.readLine())!=null){ sb.append(s) ; } String str =sb.toString(); return str; }
然后通过上面获得的 字符串 转成 JSON数据:
JSONObject aa = JSONObject.parseObject(String字符串);