From 4c23dd00ca0c9893beae386c176866a0f8cb26c7 Mon Sep 17 00:00:00 2001 From: Daeho Kwon Date: Wed, 1 Apr 2026 21:26:25 +0900 Subject: [PATCH] Support @HttpExchange in MvcUriComponentsBuilder MvcUriComponentsBuilder now recognizes @HttpExchange and composed annotations such as @GetExchange in addition to @RequestMapping when resolving class- and method-level mappings. This allows controllers that implement @HttpExchange interfaces to use fromController(), fromMethodName(), and fromMethodCall() to build links. Closes gh-36235 Signed-off-by: Daeho Kwon --- .../annotation/MvcUriComponentsBuilder.java | 41 +++++++---- .../MvcUriComponentsBuilderTests.java | 68 +++++++++++++++++++ 2 files changed, 94 insertions(+), 15 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java index b3ab0b2f0aef..5e1ee52d85a4 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java @@ -61,6 +61,7 @@ import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.annotation.RequestParamMethodArgumentResolver; import org.springframework.web.method.support.CompositeUriComponentsContributor; +import org.springframework.web.service.annotation.HttpExchange; import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping; import org.springframework.web.servlet.support.ServletUriComponentsBuilder; @@ -69,7 +70,7 @@ /** * Creates instances of {@link org.springframework.web.util.UriComponentsBuilder} - * by pointing to {@code @RequestMapping} methods on Spring MVC controllers. + * by pointing to {@code @RequestMapping} or {@code @HttpExchange} methods on Spring MVC controllers. * *

There are several groups of methods: *