开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜