当客户端提交数据后台来解析-IO
数据解析,保存遗产!强大内涵
一些看不懂的数据首先要确定他的编码格式,其次才能准确作出解析,可以拿一些数据,我博客里有一个小方法来判断是什么可是!!
BufferedReader是继承于Reader对象,从字符输入流中读取文本,缓冲各个字符,从而提供字符,数组和行的高效读取.
private String getRequestBody(HttpServletRequest request) throws IOException{ StringBuilder stringBuilder = new StringBuilder(); BufferedReader bufferedReader = null; try { InputStream inputStream = request.getInputStream(); if (inputStream != null) { bufferedReader = new BufferedReader(new InputStreamReader( inputStream,"utf-8")); char[] charBuffer = new char[128]; int bytesRead = -1; while ((bytesRead = bufferedReader.read(charBuffer)) > 0) { stringBuilder.append(charBuffer, 0, bytesRead); } } else { stringBuilder.append(""); } } catch (IOException ex) { throw ex; } finally { if (bufferedReader != null) { try { bufferedReader.close(); } catch (IOException ex) { throw ex; } } } String body = stringBuilder.toString(); log.debug("get card back body:"+body); return body; }
相关推荐
yangkang 2020-11-09
lbyd0 2020-11-17
sushuanglei 2020-11-12
85477104 2020-11-17
KANSYOUKYOU 2020-11-16
wushengyong 2020-10-28
lizhengjava 2020-11-13
星月情缘 2020-11-13
huangxiaoyun00 2020-11-13
luyong0 2020-11-08
腾讯soso团队 2020-11-06
Apsaravod 2020-11-05
PeterChangyb 2020-11-05
gaobudong 2020-11-04
wwwjun 2020-11-02
gyunwh 2020-11-02
EchoYY 2020-10-31
dingyahui 2020-10-30