Return HTTP Error 401 Code & Skip Filter Chains

后端 未结 4 798
孤街浪徒
孤街浪徒 2020-12-09 15:49

Using a custom Spring Security filter, I\'d like to return an HTTP 401 error code if the HTTP Header doesn\'t contain a particular key-value pair.

Example:



        
4条回答
  •  执念已碎
    2020-12-09 15:59

    Just do as they say in the upper answer. "so setting the response status code and returning immediately" This is just type:

    res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);  
    return;
    

提交回复
热议问题