1. 程式人生 > >java 使用全域性過濾器Filter之後 防止css檔案與js檔案被過濾

java 使用全域性過濾器Filter之後 防止css檔案與js檔案被過濾

 @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        HttpServletResponse response = (HttpServletResponse) servletResponse;
        StringBuffer server = request.getRequestURL();
        if(CookieUtils.getCookieValue(request,"account") == null){
            String ssoStatus = SSOUtils.SSOLogin(request,response,server);
            System.out.print(ssoStatus);
        }
         if(server.toString().contains(".css") || server.toString().contains(".js") || server.toString().contains(".png")|| server.toString().contains(".do")){
        //如果發現是css或者js檔案,直接放行
            chain.doFilter(request, response);
        }
        chain.doFilter(request, response);
    }