以流的方式读取url中的参数

@RequestMapping(value = "/userPreference",produces="application/json;charset=utf-8")
@ResponseBody
public String userPreference(HttpServletRequest request) {
InputStreamReader reader = null;
String json = "";
try {
request.setCharacterEncoding("UTF-8");
reader = new InputStreamReader(request.getInputStream(), "UTF-8");
char[] buff = new char[1024];
int length = 0;
while ((length = reader.read(buff)) != -1) {
String x = new String(buff, 0, length);
System.out.println(x);
json = json + x;
}
}
catch (IOException e) {
e.printStackTrace();
}


JSONObject js = JSONObject.parseObject(json);
System.out.println(js);
String uid = js.getString("uid");

}
上一篇:D3D11 IASetVertexBuffers 函数与顶点数据的两种组织方式


下一篇:python去掉文件名字里面的空格