AntPathMatcher做路徑匹配


轉發自: http://www.cnblogs.com/leftthen/p/5212221.html

 

需要看詳細的請看上面的鏈接

這里以我這里的一個Filter 中需要對路徑做例外處理,filter配置如下

<bean id="adminOnlineUserFilter" class="com.midea.finance.framework.authority.filter.AdminOnlineUserFilter">
        <property name="mdpOnllineUserService" ref="mdpOnllineUserDubboServiceClient"></property>
        <property name="logoutLink" value="${mdp.security.loginOutUrl}"></property>
        <property name="sysFlag" value="${bizSys}"></property>
        <property name="passedPaths">
            <list>
                <value>/resources/**</value>
            </list>
        </property>
    </bean>

這里的 

passedPaths 是例外配置的路徑,接收為一個 Stirng []
對例外的處理
String requestPath = req.getServletPath();
            // 路徑過濾
            PathMatcher matcher = new AntPathMatcher(); if( passedPaths != null ) { boolean flag; for( String passedPath : passedPaths ) { flag = matcher.match( passedPath, requestPath ); if( flag ) { logger.info( "AdminOnlineUserFilter source '" + requestPath + "'is matched,filter chain will be continued." ); chain.doFilter( request, response ); return; } } }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM