diff --git a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java index 6fe087e1479..d5eb532ea9b 100644 --- a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java +++ b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java @@ -35,6 +35,7 @@ import java.util.regex.Pattern; *
  • {@code ?} matches one character
  • *
  • {@code *} matches zero or more characters
  • *
  • {@code **} matches zero or more directories in a path
  • + *
  • {@code {spring:[a-z]+}} matches the regexp {@code [a-z]+} as a path variable named "spring"
  • * * *

    Examples

    @@ -50,6 +51,8 @@ import java.util.regex.Pattern; *
  • org/**/servlet/bla.jsp — matches * {@code org/springframework/servlet/bla.jsp} but also * {@code org/springframework/testing/servlet/bla.jsp} and {@code org/servlet/bla.jsp}
  • + *
  • {@code com/{filename:\\w+}.jsp} will match {@code com/test.jsp} and assign the value {@code test} + * to the {@code filename} variable
  • * * *

    Note: a pattern and a path must both be absolute or must diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistry.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistry.java index 1af469febc9..70c4f961841 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistry.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistry.java @@ -92,6 +92,9 @@ public class ResourceHandlerRegistry { * Add a resource handler for serving static resources based on the specified URL path * patterns. The handler will be invoked for every incoming request that matches to * one of the specified path patterns. + *

    Patterns like {@code "/static/**"} or {@code "/css/{filename:\\w+\\.css}"} + * are allowed. See {@link org.springframework.util.AntPathMatcher} for more details on the + * syntax. * @return A {@link ResourceHandlerRegistration} to use to further configure the * registered resource handler */ diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistry.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistry.java index 25b9311eac4..2756733d4b1 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistry.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistry.java @@ -49,6 +49,9 @@ public class ViewControllerRegistry { /** * Map a view controller to the given URL path (or pattern) in order to render * a response with a pre-configured status code and view. + *

    Patterns like {@code "/admin/**"} or {@code "/articles/{articlename:\\w+}"} + * are allowed. See {@link org.springframework.util.AntPathMatcher} for more details on the + * syntax. */ public ViewControllerRegistration addViewController(String urlPath) { ViewControllerRegistration registration = new ViewControllerRegistration(urlPath);