Add documentation of RequestMapping about SpEL

Signed-off-by: 秦利斌 <68638598+Allan-QLB@users.noreply.github.com>
This commit is contained in:
秦利斌 2025-07-22 23:34:14 +08:00 committed by rstoyanchev
parent f0a9f649c1
commit 968e037503
3 changed files with 6 additions and 2 deletions

View File

@ -237,7 +237,7 @@ Kotlin::
URI path patterns can also have embedded `${...}` placeholders that are resolved on startup URI path patterns can also have embedded `${...}` placeholders that are resolved on startup
by using `PropertySourcesPlaceholderConfigurer` against local, system, environment, and by using `PropertySourcesPlaceholderConfigurer` against local, system, environment, and
other property sources. You can use this, for example, to parameterize a base URL based on other property sources. You can use this, for example, to parameterize a base URL based on
some external configuration. some external configuration. SpEL expression `#{...}` is also supported in URI path pattern by default.
NOTE: Spring WebFlux uses `PathPattern` and the `PathPatternParser` for URI path matching support. NOTE: Spring WebFlux uses `PathPattern` and the `PathPatternParser` for URI path matching support.
Both classes are located in `spring-web` and are expressly designed for use with HTTP URL Both classes are located in `spring-web` and are expressly designed for use with HTTP URL

View File

@ -220,7 +220,7 @@ Kotlin::
URI path patterns can also have embedded `${...}` placeholders that are resolved on startup URI path patterns can also have embedded `${...}` placeholders that are resolved on startup
by using `PropertySourcesPlaceholderConfigurer` against local, system, environment, and by using `PropertySourcesPlaceholderConfigurer` against local, system, environment, and
other property sources. You can use this, for example, to parameterize a base URL based on other property sources. You can use this, for example, to parameterize a base URL based on
some external configuration. some external configuration. SpEL expression `#{...}` is also supported in URI path pattern by default.
[[mvc-ann-requestmapping-pattern-comparison]] [[mvc-ann-requestmapping-pattern-comparison]]

View File

@ -109,12 +109,16 @@ public @interface RequestMapping {
* At the method level, relative paths (for example, {@code "edit"}) are supported * At the method level, relative paths (for example, {@code "edit"}) are supported
* within the primary mapping expressed at the type level. * within the primary mapping expressed at the type level.
* Path mapping URIs may contain placeholders (for example, <code>"/${profile_path}"</code>). * Path mapping URIs may contain placeholders (for example, <code>"/${profile_path}"</code>).
* By default, SpEL expression is also supported (for example {@code "/profile/#{@bean.property}"}).
* <p><b>Supported at the type level as well as at the method level!</b> * <p><b>Supported at the type level as well as at the method level!</b>
* When used at the type level, all method-level mappings inherit * When used at the type level, all method-level mappings inherit
* this primary mapping, narrowing it for a specific handler method. * this primary mapping, narrowing it for a specific handler method.
* <p><strong>NOTE</strong>: A handler method that is not mapped to any path * <p><strong>NOTE</strong>: A handler method that is not mapped to any path
* explicitly is effectively mapped to an empty path. * explicitly is effectively mapped to an empty path.
* @since 4.2 * @since 4.2
* @see org.springframework.beans.factory.config.EmbeddedValueResolver
* @see org.springframework.context.expression.StandardBeanExpressionResolver
* @see org.springframework.context.support.AbstractApplicationContext
*/ */
@AliasFor("value") @AliasFor("value")
String[] path() default {}; String[] path() default {};