1. 程式人生 > >獲取 request 中 json 資料

獲取 request 中 json 資料

springMVC獲取請求中的json資料:都是post方式

方法一:

 http://m.blog.csdn.net/article/details?id=50149061

方法二:

InputStream is = request.getInputStream();
StringBuffer req= new StringBuffer(2048);int i;byte[] buffer1 = new byte[2048];try{ i = is.read(buffer1);}catch(IOException e) { e.printStackTrace(); i = -1;}for(int
j = 0; j < i; j++){ req.append((char) buffer1[j]);}
String str = req.toString();   

方法三:

InputStream is = request.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String bb = br.readLine();
System.out.print("llllllllllllllllll: " + bb);