I have written simple rest application using Spring MVC 4 (or Spring-Boot). Within the controller I have return ResponseEntity. But in some cases I want to give
You can return generic wildcard > to return Success and Error on a same request mapping method
public ResponseEntity> method() {
boolean b = // some logic
if (b)
return new ResponseEntity(HttpStatus.OK);
else
return new ResponseEntity(HttpStatus.CONFLICT); //appropriate error code
}
@Mark Norman answer is the correct approach