I would like to return to my Rest Client the simplest answer.
Only the:
ResponseEntity
return new ResponseEntity<String>("Custom string answer", HttpStatus.CREATED);
HttpHeaders
MultiValueMap<String, String> headers = new HttpHeaders();
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE);
return new ResponseEntity<String>("Custom string answer", headers, HttpStatus.CREATED);
As already suggested from @M.Deinum this is the easiest way:
@RequestMapping("someMapping")
@ResponseBody
public ResponseEntity<String> create() {
return ResponseEntity.status(HttpStatus.CREATED)
.contentType(MediaType.TEXT_PLAIN)
.body("Custom string answer");
}