package org.springframework.issues; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; @RestController public class TestController { @RequestMapping(name= "/testjson", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public Book handle(@RequestBody(required = false) Book body) { return new Book("Hello", "World"); } public class Book { private String title; private String author; public Book(String title, String author) { this.title = title; this.author = author; } public String getTitle() { return title; } public String getAuthor() { return author; } } }