diff --git a/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/IdcController.java b/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/IdcController.java index eaab010..ecba009 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/IdcController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/idc/controller/IdcController.java @@ -1,7 +1,5 @@ package com.glxp.sale.admin.idc.controller; -import java.io.BufferedReader; -import java.io.IOException; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; @@ -9,7 +7,6 @@ import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import org.apache.commons.lang3.StringUtils; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; @@ -98,7 +95,7 @@ public class IdcController { RestTemplate restTemplate = new RestTemplate(); - Map headerParam = getAllReaderParam(request); + Map headerParam = new HashMap<>(); Map bodyParam = new HashMap(); Enumeration pNames=request.getParameterNames(); while(pNames.hasMoreElements()){ @@ -106,12 +103,18 @@ public class IdcController { String value=request.getParameter(name); bodyParam.put(name, value); } - HttpHeaders headers = new HttpHeaders(); + Enumeration enumeration = request.getHeaderNames(); + while (enumeration.hasMoreElements()) { + String name = enumeration.nextElement(); + String value = request.getHeader(name); + headerParam.put(name, value); + headers.add(name, value); + } + + //headers.add("Content-Type", "application/json;charset=UTF-8"); - for(String key : headerParam.keySet()){ - headers.add(key, headerParam.get(key).toString()); - } + System.out.print(JSON.toJSONString(headerParam)); System.out.print(JSON.toJSONString(bodyParam)); HttpEntity http = new HttpEntity<>(JSON.toJSONString(bodyParam), headers); @@ -121,30 +124,7 @@ public class IdcController { } - private Map getAllReaderParam(HttpServletRequest request) { - Map result = new HashMap<>(); - BufferedReader br; - try { - br = request.getReader(); - if(br!=null) { - System.out.print("-----------------------"); - System.out.print(br.readLine()); - } - String str, wholeStr = ""; - while((str = br.readLine()) != null){ - wholeStr += str; - System.out.print(str); - } - if(!StringUtils.isEmpty(wholeStr)) { - result = JSON.parseObject(wholeStr); - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - return result; - } + private String parseUri(String url) { String uri = url; int a1 = uri.indexOf("://");