/** * Build the underlying interceptor. If URL patterns are provided, the returned * type is {@link MappedInterceptor}; otherwise {@link HandlerInterceptor}. */ protected Object getInterceptor() { if (this.includePatterns.isEmpty() && this.excludePatterns.isEmpty()) { return this.interceptor; } String[] include = StringUtils.toStringArray(this.includePatterns); String[] exclude = StringUtils.toStringArray(this.excludePatterns); MappedInterceptor mappedInterceptor = new MappedInterceptor(include, exclude, this.interceptor); if (this.pathMatcher != null) { mappedInterceptor.setPathMatcher(this.pathMatcher); } return mappedInterceptor; }
/** * Build the underlying interceptor. If URL patterns are provided, the returned * type is {@link MappedInterceptor}; otherwise {@link HandlerInterceptor}. */ protected Object getInterceptor() { if (this.includePatterns.isEmpty() && this.excludePatterns.isEmpty()) { return this.interceptor; } String[] include = StringUtils.toStringArray(this.includePatterns); String[] exclude = StringUtils.toStringArray(this.excludePatterns); MappedInterceptor mappedInterceptor = new MappedInterceptor(include, exclude, this.interceptor); if (this.pathMatcher != null) { mappedInterceptor.setPathMatcher(this.pathMatcher); } return mappedInterceptor; }
@Test public void customPathMatcher() { MappedInterceptor mappedInterceptor = new MappedInterceptor(new String[] { "/foo/[0-9]*" }, this.interceptor); mappedInterceptor.setPathMatcher(new TestPathMatcher()); assertTrue(mappedInterceptor.matches("/foo/123", pathMatcher)); assertFalse(mappedInterceptor.matches("/foo/bar", pathMatcher)); }
/** * Build the underlying interceptor. If URL patterns are provided, the returned * type is {@link MappedInterceptor}; otherwise {@link HandlerInterceptor}. */ protected Object getInterceptor() { if (this.includePatterns.isEmpty() && this.excludePatterns.isEmpty()) { return this.interceptor; } String[] include = StringUtils.toStringArray(this.includePatterns); String[] exclude = StringUtils.toStringArray(this.excludePatterns); MappedInterceptor mappedInterceptor = new MappedInterceptor(include, exclude, this.interceptor); if (this.pathMatcher != null) { mappedInterceptor.setPathMatcher(this.pathMatcher); } return mappedInterceptor; }