Spring REST Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 15: Line 15:
=Responses=
=Responses=


The [[@RestController]] annotation implies [[@RequestBody]], which maps the result produced by the handler method onto the body of the HTTP response.
The [[@RestController]] annotation implies [[@ResponseBody]], which maps the result produced by the handler method onto the body of the HTTP response.


=REST Clients=
=REST Clients=

Revision as of 19:44, 12 March 2019

Internal

Overview

The. Spring REST concepts page is an extension of the Spring MVC Concepts page. Spring MVC concepts are used and extended to provide REST support.

Annotations

Responses

The @RestController annotation implies @ResponseBody, which maps the result produced by the handler method onto the body of the HTTP response.

REST Clients

RestTemplate

TO PROCESS: https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#webmvc-resttemplate

POSTing Resource. Data

This overloaded version allows you to receive the newly created resource as a domain model object:

RestTemplate restTemplate = new RestTemplate();

MyResource model = new MyResource(...);

MyResource created = restTemplate.postForObject("http://localhost:8080/myresource", model, MyResource.class);