我尝试后POJO休息端点RestTemplate
Dto dto = new Dto();
dto.setPhone("12313");
RestTemplate restTemplate = new RestTemplate();
restTemplate.postForObject(new URI("http://localhost:8080/test"), dto, Dto.class);
但我收到在服务器端空DTO
@RequestMapping(value = "/test")
@ResponseBody
public DTO test123(DTO dto) {
System.out.println(dto.getPhone()); // empty
return dto;
}
DTO的是简单的POJO
public class Dto {
private String phone;
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}