From 20f89d565302f066699760815269ca62d8433e47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E5=88=A9=E6=96=8C?= <68638598+Allan-QLB@users.noreply.github.com> Date: Tue, 22 Jul 2025 23:34:14 +0800 Subject: [PATCH] Add documentation of RequestMapping about SpEL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 秦利斌 <68638598+Allan-QLB@users.noreply.github.com> --- .../ROOT/pages/web/webflux/controller/ann-requestmapping.adoc | 2 +- .../pages/web/webmvc/mvc-controller/ann-requestmapping.adoc | 2 +- .../springframework/web/bind/annotation/RequestMapping.java | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/web/webflux/controller/ann-requestmapping.adoc b/framework-docs/modules/ROOT/pages/web/webflux/controller/ann-requestmapping.adoc index 5b4e756899ad..20e6b2ad8b5c 100644 --- a/framework-docs/modules/ROOT/pages/web/webflux/controller/ann-requestmapping.adoc +++ b/framework-docs/modules/ROOT/pages/web/webflux/controller/ann-requestmapping.adoc @@ -237,7 +237,7 @@ Kotlin:: URI path patterns can also have embedded `${...}` placeholders that are resolved on startup by using `PropertySourcesPlaceholderConfigurer` against local, system, environment, and 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. Both classes are located in `spring-web` and are expressly designed for use with HTTP URL diff --git a/framework-docs/modules/ROOT/pages/web/webmvc/mvc-controller/ann-requestmapping.adoc b/framework-docs/modules/ROOT/pages/web/webmvc/mvc-controller/ann-requestmapping.adoc index 94ff1b4f420b..53d2029cd262 100644 --- a/framework-docs/modules/ROOT/pages/web/webmvc/mvc-controller/ann-requestmapping.adoc +++ b/framework-docs/modules/ROOT/pages/web/webmvc/mvc-controller/ann-requestmapping.adoc @@ -220,7 +220,7 @@ Kotlin:: URI path patterns can also have embedded `${...}` placeholders that are resolved on startup by using `PropertySourcesPlaceholderConfigurer` against local, system, environment, and 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]] diff --git a/spring-web/src/main/java/org/springframework/web/bind/annotation/RequestMapping.java b/spring-web/src/main/java/org/springframework/web/bind/annotation/RequestMapping.java index c7c1e3c70690..9655bfc99c82 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/annotation/RequestMapping.java +++ b/spring-web/src/main/java/org/springframework/web/bind/annotation/RequestMapping.java @@ -109,12 +109,16 @@ * At the method level, relative paths (for example, {@code "edit"}) are supported * within the primary mapping expressed at the type level. * Path mapping URIs may contain placeholders (for example, "/${profile_path}"). + * By default, SpEL expression is also supported (for example {@code "/profile/#{@bean.property}"}). *

Supported at the type level as well as at the method level! * When used at the type level, all method-level mappings inherit * this primary mapping, narrowing it for a specific handler method. *

NOTE: A handler method that is not mapped to any path * explicitly is effectively mapped to an empty path. * @since 4.2 + * @see org.springframework.beans.factory.config.EmbeddedValueResolver + * @see org.springframework.context.expression.StandardBeanExpressionResolver + * @see org.springframework.context.support.AbstractApplicationContext */ @AliasFor("value") String[] path() default {};