AntPathMatcher做路徑匹配
阿新 • • 發佈:2017-08-26
dmi .get let lte ole neu request gets html
轉發自: 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;
}
}
}
AntPathMatcher做路徑匹配