通常从http post请求获取数据的方法如下:
1.request.getInputStream()
2.request.getReader()
3.request.getParameterMap()系列
4.通过spring框架中的RequestBody或RequestParam

public static String req2RawString(HttpServletRequest request) {
          StringBuilder sb = new StringBuilder();
          BufferedReader reader = null;
          try {
              reader = request.getReader();
              String line;
              while ((line = reader.readLine()) != null) {
                   sb.append(line).append('\n');
              }
              if (sb.length() > 1) {
                   sb.replace(sb.length() - 1, sb.length(), "");
              }
          }
          catch (IOException e) {
              logger.info("RequestUtil,IOException:" + e);
          }
          finally {
              if (reader != null) {
                   try {
                        reader.close();
                   }
                   catch (IOException e) {
                        logger.info("RequestUtil,IOException:" + e);
                   }
              }
          }
          String str = sb.toString();
          logger.info("Request Result:" + str);
          return str;

发布评论

分享到:

IT源码网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

oracle 修改时间字段的格式讲解
你是第一个吃螃蟹的人
发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。