2

Lets say i have a Controller like this one :

@RequestMapping(method=RequestMethod.GET, value="/error")
    public  void getresponse(ModelMap modelMap) {

modelMap.addAttribute("categories", "");
}

Is it possible to send a 401 HTTP error when this controller is called? If yes, how ?

guigui42
  • 2,441
  • 8
  • 35
  • 48

1 Answers1

4

Yes its possible. Annotate it with:

@ResponseStatus(value=HttpStatus.UNAUTHORIZED)
gouki
  • 4,382
  • 3
  • 20
  • 20