[英]Spring security: how do I stop the chain with my custom code?
So, I have defined my custom filter and now I want to return in case something goes wrong:所以,我已经定义了我的自定义过滤器,现在我想返回以防出现问题:
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
if(rulefail()){
//what now??
}
filterChain.doFilter(servletRequest, servletResponse);
}
I tried throwing a runtime exception but of course it isn't effective: the server returns the tomcat's default internal server error page.我尝试抛出运行时异常,但它当然无效:服务器返回 tomcat 的默认内部服务器错误页面。
From this answer, just return or don't do filterChain.dofiler.从这个答案中,只需返回或不执行 filterChain.dofiler。 See if this answer suffice https://stackoverflow.com/a/8445927/905494
看看这个答案是否足够https://stackoverflow.com/a/8445927/905494
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.