From 908a5856fcc891c2288e9051195e91291ba446af Mon Sep 17 00:00:00 2001 From: graceyu Date: Tue, 1 Aug 2023 16:00:00 +0800 Subject: [PATCH] Provide methods for obtaining include/exclude path patterns --- .../servlet/handler/MappedInterceptor.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MappedInterceptor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MappedInterceptor.java index 2467605c77f7..f84450d76222 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MappedInterceptor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MappedInterceptor.java @@ -140,12 +140,33 @@ public MappedInterceptor(@Nullable String[] includePatterns, @Nullable String[] * Return the patterns this interceptor is mapped to. */ @Nullable + @Deprecated public String[] getPathPatterns() { return (!ObjectUtils.isEmpty(this.includePatterns) ? Arrays.stream(this.includePatterns).map(PatternAdapter::getPatternString).toArray(String[]::new) : null); } + /** + * Return the include path patterns this interceptor is mapped to. + */ + @Nullable + public String[] getIncludePathPatterns() { + return (!ObjectUtils.isEmpty(this.includePatterns) ? + Arrays.stream(this.includePatterns).map(PatternAdapter::getPatternString).toArray(String[]::new) : + null); + } + + /** + * Return the exclude path patterns this interceptor is mapped to. + */ + @Nullable + public String[] getExcludePathPatterns() { + return (!ObjectUtils.isEmpty(this.excludePatterns) ? + Arrays.stream(this.excludePatterns).map(PatternAdapter::getPatternString).toArray(String[]::new) : + null); + } + /** * The target {@link HandlerInterceptor} to invoke in case of a match. */