SpringBoot2 Filter执行两次问题解决

原因:在请求指定url之外还请求了/favicon.ico 地址 过滤掉问题就解决了

 
   


@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpServletRequest=(HttpServletRequest) request;
//favicon 不请求 否则给人执行两次的错觉
if(!httpServletRequest.getRequestURI().contains("favicon.ico")){
System.out.println(httpServletRequest.getRequestURI());
chain.doFilter(request,response);
}

}

}

转载于:https://www.cnblogs.com/coderdxj/p/11445303.html

你可能感兴趣的:(SpringBoot2 Filter执行两次问题解决)