From 39442143b70ad6e2b077ff171141f3cddbd0e5ef Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 9 Jul 2021 20:09:06 +0100 Subject: [PATCH] Fix and improve docs on {*var} pattern Closes gh-27132 --- .../springframework/web/util/pattern/PathPattern.java | 10 +++++----- src/docs/asciidoc/web/webflux.adoc | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java b/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java index 042d48a786..777b83720e 100644 --- a/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java +++ b/spring-web/src/main/java/org/springframework/web/util/pattern/PathPattern.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,10 +64,10 @@ import org.springframework.util.StringUtils; * underneath the {@code /resources/} path, including {@code /resources/image.png} * and {@code /resources/css/spring.css} *
  • /resources/{*path} — matches all files - * underneath the {@code /resources/} path and captures their relative path in - * a variable named "path"; {@code /resources/image.png} will match with - * "path" → "/image.png", and {@code /resources/css/spring.css} will match - * with "path" → "/css/spring.css"
  • + * underneath the {@code /resources/}, as well as {@code /resources}, and captures + * their relative path in a variable named "path"; {@code /resources/image.png} + * will match with "path" → "/image.png", and {@code /resources/css/spring.css} + * will match with "path" → "/css/spring.css" *
  • /resources/{filename:\\w+}.dat will match {@code /resources/spring.dat} * and assign the value {@code "spring"} to the {@code filename} variable
  • * diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index 132c2dfff3..3b601ea4c8 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -1448,7 +1448,7 @@ You can map requests by using glob patterns and wildcards: | `+{*path}+` | Matches zero or more path segments until the end of the path and captures it as a variable named "path" -| `+"/resources/{*file}"+` matches `+"/resources/images/file.png"+` and captures `+file=images/file.png+` +| `+"/resources/{*file}"+` matches `+"/resources/images/file.png"+` and captures `+file=/images/file.png+` |=== @@ -1517,7 +1517,7 @@ information or with the `-parameters` compiler flag on Java 8. The syntax `{*varName}` declares a URI variable that matches zero or more remaining path segments. For example `/resources/{*path}` matches all files under `/resources/`, and the -`"path"` variable captures the complete relative path. +`"path"` variable captures the complete path under `/resources`. The syntax `{varName:regex}` declares a URI variable with a regular expression that has the syntax: `{varName:regex}`. For example, given a URL of `/spring-web-3.0.5.jar`, the following method