请问:我有一个get方法,在postman中可以获取到body。但是用另外一个方法向这个url发送请求时,无法接收到body是为什么.
@GetMapping ("/ip")
// , @RequestBody Object body
public Object getIp( HttpServletRequest request,@RequestBody Object body ) throws IOException {
System.out.println( body );
return body;
}
@GetMapping("/submitIp")
public String getIpByThisIp(HttpServletRequest request){
String authorization = request.getHeader( "authorization" );
String url = "http://localhost:30999/httpbin/ip";
HttpHeaders headers = new HttpHeaders();
headers.setContentType( MediaType.APPLICATION_JSON );
String jsonAuthorization = JSONObject.toJSONString( authorization );
HttpEntity entity = new HttpEntity( jsonAuthorization,headers );
HttpMethod method = HttpMethod.GET;
ResponseEntity< String > exchange = restTemplate.exchange( url, method, entity, String.class );
return "ok";
}