0
点赞
收藏
分享

微信扫一扫

restTemplate详解

实践

@Resource
private RestTemplate template;

@PostMapping("/v1/third/add/person")
public void postAddPerson(@RequestBody Person person){
String url = "http://localhost:8081/post/string";
//final Map<String, Object> map = beanToMap(person);
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<String, Object>();
paramMap.set("name","tom");
String respnose = template.postForObject(url, paramMap, String.class);
System.out.println(JSON.toJSONString(respnose));
}

案例

​​RestTemplate post请求传参方式​​

bug

​​如何解决component required a bean of type ‘org.springframework.web.client.RestTempla​​


举报

相关推荐

0 条评论