![](/img/trans.png)
[英]How do I create a custom JSON 401 page for my Spring MVC/Security restful web service?
[英]Spring security: how do I stop the chain with my custom code?
所以,我已经定义了我的自定义过滤器,现在我想返回以防出现问题:
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
if(rulefail()){
//what now??
}
filterChain.doFilter(servletRequest, servletResponse);
}
我尝试抛出运行时异常,但它当然无效:服务器返回 tomcat 的默认内部服务器错误页面。
从这个答案中,只需返回或不执行 filterChain.dofiler。 看看这个答案是否足够https://stackoverflow.com/a/8445927/905494
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.