Spring sending 401 HTTP response via Controller
Lets say i have a Controller like this one :
@RequestMap开发者_StackOverflow中文版ping(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 ?
Yes its possible. Annotate it with:
@ResponseStatus(value=HttpStatus.UNAUTHORIZED)
精彩评论