January 2018
Intermediate to advanced
414 pages
10h 29m
English
When we define our POST method to create customers, we define it in the following way:
@PostMapping(value = "/customer/")fun createCustomer(@RequestBody customer: Customer): ResponseEntity<Unit?> { customerService.createCustomer(customer) return ResponseEntity(null, HttpStatus.CREATED)}
Then, when a request is sent, for example as this cURL request:
curl -X POST \ http://localhost:8080/customer/ \ -H 'content-type: application/json' \ -d '{ "id": 4, "name": "New Customer"}'
Spring will get the body of the request and use the ObjectMapper to construct a JVM object of the specified class. The object mapper using reflection will find all the public attributes or setter methods for each property in the JSON object, ...
Read now
Unlock full access