获取http-post请求的原生报文
BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream(), "utf-8")); StringBuffer sb = new StringBuffer(""); String temp; while ((temp = br.readLine()) != null) { sb.append(temp); } br.close();
Pojo dto = gson.fromJson(params, Pojo.class);
这个是最原始的servlet获取方式,如果是使用spring可以直接用@RequestBody来接收为一个对象;