Merge branch '2.7.x' into 3.0.x

Closes gh-38017
This commit is contained in:
Andy Wilkinson 2023-10-25 10:44:03 +01:00
commit b33ee84146
2 changed files with 10 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 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.
@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.web.servlet;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
@ -25,9 +26,12 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
* Interface to register key components of the {@link WebMvcConfigurationSupport} in place
* of the default ones provided by Spring MVC.
* <p>
* All custom instances are later processed by Boot and Spring MVC configurations. A
* single instance of this component should be registered, otherwise making it impossible
* to choose from redundant MVC components.
* All custom instances are later processed by Boot and Spring MVC configurations. To
* participate in, and if desired, override that subsequent processing,
* {@link WebMvcConfigurer} should be used.
* <p>
* A single instance of this component should be registered, otherwise making it
* impossible to choose from redundant MVC components.
*
* @author Brian Clozel
* @since 2.0.0

View File

@ -45,6 +45,8 @@ In addition to Spring MVC's defaults, the auto-configuration provides the follow
If you want to keep those Spring Boot MVC customizations and make more {spring-framework-docs}/web.html#mvc[MVC customizations] (interceptors, formatters, view controllers, and other features), you can add your own `@Configuration` class of type `WebMvcConfigurer` but *without* `@EnableWebMvc`.
If you want to provide custom instances of `RequestMappingHandlerMapping`, `RequestMappingHandlerAdapter`, or `ExceptionHandlerExceptionResolver`, and still keep the Spring Boot MVC customizations, you can declare a bean of type `WebMvcRegistrations` and use it to provide custom instances of those components.
The custom instances will be subject to further initialization and configuration by Spring MVC.
To participate in, and if desired, override that subsequent processing, a `WebMvcConfigurer` should be used.
If you do not want to use the auto-configuration and want to take complete control of Spring MVC, add your own `@Configuration` annotated with `@EnableWebMvc`.
Alternatively, add your own `@Configuration`-annotated `DelegatingWebMvcConfiguration` as described in the Javadoc of `@EnableWebMvc`.