change your return type to ResponseEntity<>
, then you can use below for 400
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
and for correct request
return new ResponseEntity<>(json,HttpStatus.OK);
UPDATE 1
after spring 4.1 there are helper methods in ResponseEntity could be used as
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
and
return ResponseEntity.ok(json);