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 8ab70c574a2..90e22574f8b 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 @@ -436,8 +436,8 @@ attributes with a narrower, more specific purpose. `@GetMapping`, `@PostMapping`, `@PutMapping`, `@DeleteMapping`, and `@PatchMapping` are examples of composed annotations. They are provided, because, arguably, most controller methods should be mapped to a specific HTTP method versus using `@RequestMapping`, -which, by default, matches to all HTTP methods. If you need an example of composed -annotations, look at how those are declared. +which, by default, matches to all HTTP methods. If you need an example of how to implement +a composed annotation, look at how those are declared. Spring WebFlux also supports custom request mapping attributes with custom request matching logic. This is a more advanced option that requires sub-classing 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 e0c1fb5a905..5e573f1e470 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 @@ -486,8 +486,8 @@ attributes with a narrower, more specific purpose. `@GetMapping`, `@PostMapping`, `@PutMapping`, `@DeleteMapping`, and `@PatchMapping` are examples of composed annotations. They are provided because, arguably, most controller methods should be mapped to a specific HTTP method versus using `@RequestMapping`, -which, by default, matches to all HTTP methods. If you need an example of composed -annotations, look at how those are declared. +which, by default, matches to all HTTP methods. If you need an example of how to implement +a composed annotation, look at how those are declared. Spring MVC also supports custom request-mapping attributes with custom request-matching logic. This is a more advanced option that requires subclassing 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 9a677fa13fe..624281339e2 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -31,7 +31,7 @@ import org.springframework.core.annotation.AliasFor; * *
Both Spring MVC and Spring WebFlux support this annotation through a * {@code RequestMappingHandlerMapping} and {@code RequestMappingHandlerAdapter} - * in their respective modules and package structure. For the exact list of + * in their respective modules and package structures. For the exact list of * supported handler method arguments and return types in each, please use the * reference documentation links below: *
Note: This annotation can be used both at the class and + *
NOTE: This annotation can be used both at the class and * at the method level. In most cases, at the method level applications will * prefer to use one of the HTTP method specific variants * {@link GetMapping @GetMapping}, {@link PostMapping @PostMapping}, * {@link PutMapping @PutMapping}, {@link DeleteMapping @DeleteMapping}, or - * {@link PatchMapping @PatchMapping}.
+ * {@link PatchMapping @PatchMapping}. * *NOTE: When using controller interfaces (e.g. for AOP proxying), - * make sure to consistently put all your mapping annotations - such as - * {@code @RequestMapping} and {@code @SessionAttributes} - on + * make sure to consistently put all your mapping annotations — such + * as {@code @RequestMapping} and {@code @SessionAttributes} — on * the controller interface rather than on the implementation class. * * @author Juergen Hoeller @@ -87,21 +87,17 @@ public @interface RequestMapping { String name() default ""; /** - * The primary mapping expressed by this annotation. + * The path mapping URIs — for example, {@code "/profile"}. *
This is an alias for {@link #path}. For example, - * {@code @RequestMapping("/foo")} is equivalent to - * {@code @RequestMapping(path="/foo")}. - *
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. + * {@code @RequestMapping("/profile")} is equivalent to + * {@code @RequestMapping(path="/profile")}. + *
See {@link #path} for further details. */ @AliasFor("path") String[] value() default {}; /** - * The path mapping URIs (e.g. {@code "/profile"}). + * The path mapping URIs — for example, {@code "/profile"}. *
Ant-style path patterns are also supported (e.g. {@code "/profile/**"}). * At the method level, relative paths (e.g. {@code "edit"}) are supported * within the primary mapping expressed at the type level.