How do I get a Spring 3.0 controller to trigger a 404?
I have a controller with @RequestMapping(value = \"/**\", method = RequestMethod.GET) and for som
@RequestMapping(value = \"/**\", method = RequestMethod.GET)
Since Spring 3.0.2 you can return ResponseEntity as a result of the controller's method:
@RequestMapping..... public ResponseEntity handleCall() { if (isFound()) { // do what you want return new ResponseEntity<>(HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } }
(ResponseEntity is a more flexible than @ResponseBody annotation - see another question)