Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CustomerDTO {
- private String name;
- private String email;
- public CustomerDTO(String name, String email) {
- this.name = name;
- this.email = email;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getName() {
- return name;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public String getEmail() {
- return email;
- }
- }
- public class RestTemplateDemo {
- public static void main(String args[]) {
- RestTemplate restTemplate = new RestTemplate();
- String customerAPIUrl = "http://localhost:9080/api/customer";
- ResponseEntity <CustomerDTO> customerEntity = restTemplate.exchange(customerAPIUrl, HttpMethod.POST, request, CustomerDTO.class);
- System.out.println("Name:" + customerEntity.getBody().getName());
- System.out.println("Email:" + customerEntity.getBody().getEmail());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment