diff --git a/framework-docs/modules/ROOT/pages/web/webflux/controller/ann.adoc b/framework-docs/modules/ROOT/pages/web/webflux/controller/ann.adoc
index 93cc097b15..602d2b591a 100644
--- a/framework-docs/modules/ROOT/pages/web/webflux/controller/ann.adoc
+++ b/framework-docs/modules/ROOT/pages/web/webflux/controller/ann.adoc
@@ -20,7 +20,7 @@ Java::
----
@Configuration
@ComponentScan("org.example.web") // <1>
- public class WebConfig {
+ public class WebConfiguration {
// ...
}
@@ -33,7 +33,7 @@ Kotlin::
----
@Configuration
@ComponentScan("org.example.web") // <1>
- class WebConfig {
+ class WebConfiguration {
// ...
}
diff --git a/framework-docs/modules/ROOT/pages/web/webmvc/mvc-controller/ann.adoc b/framework-docs/modules/ROOT/pages/web/webmvc/mvc-controller/ann.adoc
index b6495f54dd..493d1d74d5 100644
--- a/framework-docs/modules/ROOT/pages/web/webmvc/mvc-controller/ann.adoc
+++ b/framework-docs/modules/ROOT/pages/web/webmvc/mvc-controller/ann.adoc
@@ -12,54 +12,7 @@ annotated class, indicating its role as a web component.
To enable auto-detection of such `@Controller` beans, you can add component scanning to
your Java configuration, as the following example shows:
-[tabs]
-======
-Java::
-+
-[source,java,indent=0,subs="verbatim,quotes",role="primary"]
-----
- @Configuration
- @ComponentScan("org.example.web")
- public class WebConfig {
-
- // ...
- }
-----
-
-Kotlin::
-+
-[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
-----
- @Configuration
- @ComponentScan("org.example.web")
- class WebConfig {
-
- // ...
- }
-----
-======
-
-The following example shows the XML configuration equivalent of the preceding example:
-
-[source,xml,indent=0,subs="verbatim,quotes"]
-----
-
-
-
-
-
-
-
-
-----
+include-code::./WebConfiguration[tag=snippet,indent=0]
`@RestController` is a xref:core/beans/classpath-scanning.adoc#beans-meta-annotations[composed annotation] that is
itself meta-annotated with `@Controller` and `@ResponseBody` to indicate a controller whose
diff --git a/framework-docs/src/main/java/org/springframework/docs/web/webmvc/mvccontroller/mvcanncontroller/WebConfiguration.java b/framework-docs/src/main/java/org/springframework/docs/web/webmvc/mvccontroller/mvcanncontroller/WebConfiguration.java
new file mode 100644
index 0000000000..84aab1258c
--- /dev/null
+++ b/framework-docs/src/main/java/org/springframework/docs/web/webmvc/mvccontroller/mvcanncontroller/WebConfiguration.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.docs.web.webmvc.mvccontroller.mvcanncontroller;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+// tag::snippet[]
+@Configuration
+@ComponentScan("org.example.web")
+public class WebConfiguration {
+
+ // ...
+}
+// end::snippet[]
diff --git a/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvc/mvccontroller/mvcanncontroller/WebConfiguration.kt b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvc/mvccontroller/mvcanncontroller/WebConfiguration.kt
new file mode 100644
index 0000000000..410b77ff06
--- /dev/null
+++ b/framework-docs/src/main/kotlin/org/springframework/docs/web/webmvc/mvccontroller/mvcanncontroller/WebConfiguration.kt
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.docs.web.webmvc.mvccontroller.mvcanncontroller
+
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+// tag::snippet[]
+@Configuration
+@ComponentScan("org.example.web")
+class WebConfiguration {
+
+ // ...
+}
+// end::snippet[]
diff --git a/framework-docs/src/main/resources/org/springframework/docs/web/webmvc/mvccontroller/mvcanncontroller/WebConfiguration.xml b/framework-docs/src/main/resources/org/springframework/docs/web/webmvc/mvccontroller/mvcanncontroller/WebConfiguration.xml
new file mode 100644
index 0000000000..e3ceacddb0
--- /dev/null
+++ b/framework-docs/src/main/resources/org/springframework/docs/web/webmvc/mvccontroller/mvcanncontroller/WebConfiguration.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file