Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
7df3d68b
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7df3d68b
编写于
4月 20, 2017
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace WebMvcConfigurerAdapter with default methods
Issue: SPR-15465
上级
d3b178a8
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
165 addition
and
123 deletion
+165
-123
spring-test/src/test/java/org/springframework/test/web/client/samples/MockMvcClientHttpRequestFactoryTests.java
.../client/samples/MockMvcClientHttpRequestFactoryTests.java
+2
-2
spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/AsyncControllerJavaConfigTests.java
...rvlet/samples/context/AsyncControllerJavaConfigTests.java
+7
-5
spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/JavaConfigTests.java
...ork/test/web/servlet/samples/context/JavaConfigTests.java
+11
-8
spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/CustomRequestAttributesRequestContextHolderTests.java
...spr/CustomRequestAttributesRequestContextHolderTests.java
+9
-7
spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/EncodedUriTests.java
...amework/test/web/servlet/samples/spr/EncodedUriTests.java
+7
-6
spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/HttpOptionsTests.java
...mework/test/web/servlet/samples/spr/HttpOptionsTests.java
+6
-6
spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/MockMvcBuilderMethodChainTests.java
...b/servlet/samples/spr/MockMvcBuilderMethodChainTests.java
+3
-3
spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/RequestContextHolderTests.java
...st/web/servlet/samples/spr/RequestContextHolderTests.java
+10
-8
spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/EnableWebMvc.java
...framework/web/servlet/config/annotation/EnableWebMvc.java
+3
-5
spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java
...servlet/config/annotation/WebMvcConfigurationSupport.java
+0
-1
spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurer.java
...ework/web/servlet/config/annotation/WebMvcConfigurer.java
+44
-25
spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurerAdapter.java
...eb/servlet/config/annotation/WebMvcConfigurerAdapter.java
+4
-0
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java
...ork/web/servlet/resource/AppCacheManifestTransformer.java
+1
-1
spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java
...config/annotation/DelegatingWebMvcConfigurationTests.java
+10
-5
spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolutionIntegrationTests.java
...let/config/annotation/ViewResolutionIntegrationTests.java
+2
-2
spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportTests.java
...et/config/annotation/WebMvcConfigurationSupportTests.java
+2
-3
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java
...t/mvc/method/annotation/MvcUriComponentsBuilderTests.java
+13
-5
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java
...et/mvc/method/annotation/RequestPartIntegrationTests.java
+4
-4
src/docs/asciidoc/web/web-cors.adoc
src/docs/asciidoc/web/web-cors.adoc
+2
-2
src/docs/asciidoc/web/web-mvc.adoc
src/docs/asciidoc/web/web-mvc.adoc
+21
-21
src/docs/asciidoc/web/web-view.adoc
src/docs/asciidoc/web/web-view.adoc
+4
-4
未找到文件。
spring-test/src/test/java/org/springframework/test/web/client/samples/MockMvcClientHttpRequestFactoryTests.java
浏览文件 @
7df3d68b
...
...
@@ -38,7 +38,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.context.WebApplicationContext
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
Adapter
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
...
...
@@ -87,7 +87,7 @@ public class MockMvcClientHttpRequestFactoryTests {
@EnableWebMvc
@Configuration
@ComponentScan
(
basePackageClasses
=
MockMvcClientHttpRequestFactoryTests
.
class
)
static
class
MyWebConfig
extends
WebMvcConfigurerAdapt
er
{
static
class
MyWebConfig
implements
WebMvcConfigur
er
{
}
@Controller
...
...
spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/AsyncControllerJavaConfigTests.java
浏览文件 @
7df3d68b
...
...
@@ -42,12 +42,14 @@ import org.springframework.web.context.WebApplicationContext;
import
org.springframework.web.context.request.async.CallableProcessingInterceptor
;
import
org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
Adapter
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
static
org
.
mockito
.
ArgumentMatchers
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.*;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
asyncDispatch
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
request
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
/**
* Tests with Java configuration.
...
...
@@ -100,7 +102,7 @@ public class AsyncControllerJavaConfigTests {
@Configuration
@EnableWebMvc
static
class
WebConfig
extends
WebMvcConfigurerAdapt
er
{
static
class
WebConfig
implements
WebMvcConfigur
er
{
@Override
public
void
configureAsyncSupport
(
AsyncSupportConfigurer
configurer
)
{
...
...
spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/JavaConfigTests.java
浏览文件 @
7df3d68b
...
...
@@ -21,7 +21,6 @@ import javax.servlet.ServletContext;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mockito
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -44,14 +43,18 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.ViewControllerRegistry
;
import
org.springframework.web.servlet.config.annotation.ViewResolverRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
Adapter
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
org.springframework.web.servlet.view.tiles3.TilesConfigurer
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
BDDMockito
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultHandlers
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.*;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertSame
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultHandlers
.
print
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
forwardedUrl
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
/**
* Tests with Java configuration.
...
...
@@ -142,7 +145,7 @@ public class JavaConfigTests {
@Configuration
@EnableWebMvc
static
class
WebConfig
extends
WebMvcConfigurerAdapt
er
{
static
class
WebConfig
implements
WebMvcConfigur
er
{
@Autowired
private
RootConfig
rootConfig
;
...
...
spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/CustomRequestAttributesRequestContextHolderTests.java
浏览文件 @
7df3d68b
...
...
@@ -39,13 +39,15 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import
org.springframework.web.context.request.ServletWebRequest
;
import
org.springframework.web.context.support.GenericWebApplicationContext
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
Adapter
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
static
org
.
hamcrest
.
CoreMatchers
.*;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
setup
.
MockMvcBuilders
.*;
import
static
org
.
hamcrest
.
CoreMatchers
.
instanceOf
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
hamcrest
.
CoreMatchers
.
nullValue
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
setup
.
MockMvcBuilders
.
webAppContextSetup
;
/**
* Integration tests for SPR-13211 which verify that a custom mock request
...
...
@@ -107,7 +109,7 @@ public class CustomRequestAttributesRequestContextHolderTests {
@Configuration
@EnableWebMvc
static
class
WebConfig
extends
WebMvcConfigurerAdapt
er
{
static
class
WebConfig
implements
WebMvcConfigur
er
{
@Bean
public
SingletonController
singletonController
()
{
...
...
spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/EncodedUriTests.java
浏览文件 @
7df3d68b
...
...
@@ -43,14 +43,15 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.context.WebApplicationContext
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.ViewResolverRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
Adapter
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
;
import
org.springframework.web.util.UriComponentsBuilder
;
import
static
org
.
hamcrest
.
core
.
Is
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
setup
.
MockMvcBuilders
.*;
import
static
org
.
hamcrest
.
core
.
Is
.
is
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
model
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
setup
.
MockMvcBuilders
.
webAppContextSetup
;
/**
* Tests for SPR-11441 (MockMvc accepts an already encoded URI).
...
...
@@ -83,7 +84,7 @@ public class EncodedUriTests {
@Configuration
@EnableWebMvc
static
class
WebConfig
extends
WebMvcConfigurerAdapt
er
{
static
class
WebConfig
implements
WebMvcConfigur
er
{
@Bean
public
MyController
myController
()
{
...
...
spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/HttpOptionsTests.java
浏览文件 @
7df3d68b
...
...
@@ -35,12 +35,12 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.context.WebApplicationContext
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
Adapter
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
static
org
.
junit
.
Assert
.
*
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
*
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
*
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
setup
.
MockMvcBuilders
.
*
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
options
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
setup
.
MockMvcBuilders
.
webAppContextSetup
;
/**
* Tests for SPR-10093 (support for OPTIONS requests).
...
...
@@ -75,7 +75,7 @@ public class HttpOptionsTests {
@Configuration
@EnableWebMvc
static
class
WebConfig
extends
WebMvcConfigurerAdapt
er
{
static
class
WebConfig
implements
WebMvcConfigur
er
{
@Bean
public
MyController
myController
()
{
...
...
spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/MockMvcBuilderMethodChainTests.java
浏览文件 @
7df3d68b
...
...
@@ -27,9 +27,9 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import
org.springframework.web.context.WebApplicationContext
;
import
org.springframework.web.filter.CharacterEncodingFilter
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
Adapter
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
*
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
/**
* Test for SPR-10277 (multiple method chaining when building MockMvc).
...
...
@@ -55,6 +55,6 @@ public class MockMvcBuilderMethodChainTests {
@Configuration
@EnableWebMvc
static
class
WebConfig
extends
WebMvcConfigurerAdapt
er
{
static
class
WebConfig
implements
WebMvcConfigur
er
{
}
}
spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/RequestContextHolderTests.java
浏览文件 @
7df3d68b
...
...
@@ -17,7 +17,6 @@
package
org.springframework.test.web.servlet.samples.spr
;
import
java.io.IOException
;
import
javax.servlet.FilterChain
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletRequest
;
...
...
@@ -48,13 +47,16 @@ import org.springframework.web.context.request.RequestContextHolder;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
org.springframework.web.filter.GenericFilterBean
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
Adapter
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
static
org
.
hamcrest
.
CoreMatchers
.*;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
setup
.
MockMvcBuilders
.*;
import
static
org
.
hamcrest
.
CoreMatchers
.
instanceOf
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
hamcrest
.
CoreMatchers
.
nullValue
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
setup
.
MockMvcBuilders
.
webAppContextSetup
;
/**
* Integration tests for the following use cases.
...
...
@@ -145,7 +147,7 @@ public class RequestContextHolderTests {
@Configuration
@EnableWebMvc
static
class
WebConfig
extends
WebMvcConfigurerAdapt
er
{
static
class
WebConfig
implements
WebMvcConfigur
er
{
@Bean
public
SingletonController
singletonController
()
{
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/EnableWebMvc.java
浏览文件 @
7df3d68b
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
7
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.
...
...
@@ -38,14 +38,13 @@ import org.springframework.context.annotation.Import;
* </pre>
*
* <p>To customize the imported configuration, implement the interface
* {@link WebMvcConfigurer} or more likely extend the empty method base class
* {@link WebMvcConfigurerAdapter} and override individual methods, e.g.:
* {@link WebMvcConfigurer} and override individual methods, e.g.:
*
* <pre class="code">
* @Configuration
* @EnableWebMvc
* @ComponentScan(basePackageClasses = MyConfiguration.class)
* public class MyConfiguration
extends WebMvcConfigurerAdapt
er {
* public class MyConfiguration
implements WebMvcConfigur
er {
*
* @Override
* public void addFormatters(FormatterRegistry formatterRegistry) {
...
...
@@ -93,7 +92,6 @@ import org.springframework.context.annotation.Import;
* @author Rossen Stoyanchev
* @since 3.1
* @see org.springframework.web.servlet.config.annotation.WebMvcConfigurer
* @see org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
* @see org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
* @see org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration
*/
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java
浏览文件 @
7df3d68b
...
...
@@ -168,7 +168,6 @@ import org.springframework.web.util.UrlPathHelper;
* @since 3.1
* @see EnableWebMvc
* @see WebMvcConfigurer
* @see WebMvcConfigurerAdapter
*/
public
class
WebMvcConfigurationSupport
implements
ApplicationContextAware
,
ServletContextAware
{
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurer.java
浏览文件 @
7df3d68b
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
7
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.
...
...
@@ -36,8 +36,7 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
*
* <p>{@code @EnableWebMvc}-annotated configuration classes may implement
* this interface to be called back and given a chance to customize the
* default configuration. Consider extending {@link WebMvcConfigurerAdapter},
* which provides a stub implementation of all interface methods.
* default configuration.
*
* @author Rossen Stoyanchev
* @author Keith Donald
...
...
@@ -57,17 +56,20 @@ public interface WebMvcConfigurer {
* </ul>
* @since 4.0.3
*/
void
configurePathMatch
(
PathMatchConfigurer
configurer
);
default
void
configurePathMatch
(
PathMatchConfigurer
configurer
)
{
}
/**
* Configure content negotiation options.
*/
void
configureContentNegotiation
(
ContentNegotiationConfigurer
configurer
);
default
void
configureContentNegotiation
(
ContentNegotiationConfigurer
configurer
)
{
}
/**
* Configure asynchronous request handling options.
*/
void
configureAsyncSupport
(
AsyncSupportConfigurer
configurer
);
default
void
configureAsyncSupport
(
AsyncSupportConfigurer
configurer
)
{
}
/**
* Configure a handler to delegate unhandled requests by forwarding to the
...
...
@@ -75,13 +77,15 @@ public interface WebMvcConfigurer {
* the {@link DispatcherServlet} is mapped to "/" thus overriding the
* Servlet container's default handling of static resources.
*/
void
configureDefaultServletHandling
(
DefaultServletHandlerConfigurer
configurer
);
default
void
configureDefaultServletHandling
(
DefaultServletHandlerConfigurer
configurer
)
{
}
/**
* Add {@link Converter}s and {@link Formatter}s in addition to the ones
* registered by default.
*/
void
addFormatters
(
FormatterRegistry
registry
);
default
void
addFormatters
(
FormatterRegistry
registry
)
{
}
/**
* Add Spring MVC lifecycle interceptors for pre- and post-processing of
...
...
@@ -95,20 +99,23 @@ public interface WebMvcConfigurer {
* {@link org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
* WebMvcConfigurationSupport} and then override {@code resourceHandlerMapping}.
*/
void
addInterceptors
(
InterceptorRegistry
registry
);
default
void
addInterceptors
(
InterceptorRegistry
registry
)
{
}
/**
* Add handlers to serve static resources such as images, js, and, css
* files from specific locations under web application root, the classpath,
* and others.
*/
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
);
default
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
}
/**
* Configure cross origin requests processing.
* @since 4.2
*/
void
addCorsMappings
(
CorsRegistry
registry
);
default
void
addCorsMappings
(
CorsRegistry
registry
)
{
}
/**
* Configure simple automated controllers pre-configured with the response
...
...
@@ -117,7 +124,8 @@ public interface WebMvcConfigurer {
* home page, perform simple site URL redirects, return a 404 status with
* HTML content, a 204 with no content, and more.
*/
void
addViewControllers
(
ViewControllerRegistry
registry
);
default
void
addViewControllers
(
ViewControllerRegistry
registry
)
{
}
/**
* Configure view resolvers to translate String-based view names returned from
...
...
@@ -125,25 +133,28 @@ public interface WebMvcConfigurer {
* implementations to perform rendering with.
* @since 4.1
*/
void
configureViewResolvers
(
ViewResolverRegistry
registry
);
default
void
configureViewResolvers
(
ViewResolverRegistry
registry
)
{
}
/**
* Add resolvers to support custom controller method argument types.
* <p>This does not override the built-in support for resolving handler
* method arguments. To customize the built-in support for argument
* resolution, configure {@link RequestMappingHandlerAdapter} directly.
* @param
argumentR
esolvers initially an empty list
* @param
r
esolvers initially an empty list
*/
void
addArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
argumentResolvers
);
default
void
addArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
resolvers
)
{
}
/**
* Add handlers to support custom controller method return value types.
* <p>Using this option does not override the built-in support for handling
* return values. To customize the built-in support for handling return
* values, configure RequestMappingHandlerAdapter directly.
* @param
returnValueH
andlers initially an empty list
* @param
h
andlers initially an empty list
*/
void
addReturnValueHandlers
(
List
<
HandlerMethodReturnValueHandler
>
returnValueHandlers
);
default
void
addReturnValueHandlers
(
List
<
HandlerMethodReturnValueHandler
>
handlers
)
{
}
/**
* Configure the {@link HttpMessageConverter}s to use for reading or writing
...
...
@@ -155,7 +166,8 @@ public interface WebMvcConfigurer {
* {@link #extendMessageConverters(java.util.List)} instead.
* @param converters initially an empty list of converters
*/
void
configureMessageConverters
(
List
<
HttpMessageConverter
<?>>
converters
);
default
void
configureMessageConverters
(
List
<
HttpMessageConverter
<?>>
converters
)
{
}
/**
* A hook for extending or modifying the list of converters after it has been
...
...
@@ -164,7 +176,8 @@ public interface WebMvcConfigurer {
* @param converters the list of configured converters to extend.
* @since 4.1.3
*/
void
extendMessageConverters
(
List
<
HttpMessageConverter
<?>>
converters
);
default
void
extendMessageConverters
(
List
<
HttpMessageConverter
<?>>
converters
)
{
}
/**
* Configure exception resolvers.
...
...
@@ -177,21 +190,23 @@ public interface WebMvcConfigurer {
* <p>Alternatively you can use
* {@link #extendHandlerExceptionResolvers(List)} which allows you to extend
* or modify the list of exception resolvers configured by default.
* @param
exceptionR
esolvers initially an empty list
* @param
r
esolvers initially an empty list
* @see #extendHandlerExceptionResolvers(List)
* @see WebMvcConfigurationSupport#addDefaultHandlerExceptionResolvers(List)
*/
void
configureHandlerExceptionResolvers
(
List
<
HandlerExceptionResolver
>
exceptionResolvers
);
default
void
configureHandlerExceptionResolvers
(
List
<
HandlerExceptionResolver
>
resolvers
)
{
}
/**
* Extending or modify the list of exception resolvers configured by default.
* This can be useful for inserting a custom exception resolver without
* interfering with default ones.
* @param
exceptionR
esolvers the list of configured resolvers to extend
* @param
r
esolvers the list of configured resolvers to extend
* @since 4.3
* @see WebMvcConfigurationSupport#addDefaultHandlerExceptionResolvers(List)
*/
void
extendHandlerExceptionResolvers
(
List
<
HandlerExceptionResolver
>
exceptionResolvers
);
default
void
extendHandlerExceptionResolvers
(
List
<
HandlerExceptionResolver
>
resolvers
)
{
}
/**
* Provide a custom {@link Validator} instead of the one created by default.
...
...
@@ -199,13 +214,17 @@ public interface WebMvcConfigurer {
* {@link org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean}.
* Leave the return value as {@code null} to keep the default.
*/
Validator
getValidator
();
default
Validator
getValidator
()
{
return
null
;
}
/**
* Provide a custom {@link MessageCodesResolver} for building message codes
* from data binding and validation error codes. Leave the return value as
* {@code null} to keep the default.
*/
MessageCodesResolver
getMessageCodesResolver
();
default
MessageCodesResolver
getMessageCodesResolver
()
{
return
null
;
}
}
spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurerAdapter.java
浏览文件 @
7df3d68b
...
...
@@ -32,7 +32,11 @@ import org.springframework.web.servlet.HandlerExceptionResolver;
*
* @author Rossen Stoyanchev
* @since 3.1
* @deprecated as of 5.0 {@link WebMvcConfigurer} has default methods (made
* possible by a Java 8 baseline) and can be implemented directly without the
* need for this adapter
*/
@Deprecated
public
abstract
class
WebMvcConfigurerAdapter
implements
WebMvcConfigurer
{
/**
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java
浏览文件 @
7df3d68b
...
...
@@ -55,7 +55,7 @@ import org.springframework.util.StringUtils;
* <p>In order to serve manifest files with the proper {@code "text/manifest"} content type,
* it is required to configure it with
* {@code contentNegotiationConfigurer.mediaType("appcache", MediaType.valueOf("text/manifest")}
* in a {@code WebMvcConfigurer
Adapter
}.
* in a {@code WebMvcConfigurer}.
*
* @author Brian Clozel
* @since 4.1
...
...
spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java
浏览文件 @
7df3d68b
...
...
@@ -46,8 +46,13 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
import
org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver
;
import
org.springframework.web.util.UrlPathHelper
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
BDDMockito
.*;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertSame
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
BDDMockito
.
mock
;
import
static
org
.
mockito
.
BDDMockito
.
verify
;
/**
* A test fixture for {@link DelegatingWebMvcConfiguration} tests.
...
...
@@ -118,7 +123,7 @@ public class DelegatingWebMvcConfigurationTests {
final
HttpMessageConverter
customConverter
=
mock
(
HttpMessageConverter
.
class
);
final
StringHttpMessageConverter
stringConverter
=
new
StringHttpMessageConverter
();
List
<
WebMvcConfigurer
>
configurers
=
new
ArrayList
<>();
configurers
.
add
(
new
WebMvcConfigurer
Adapter
()
{
configurers
.
add
(
new
WebMvcConfigurer
()
{
@Override
public
void
configureMessageConverters
(
List
<
HttpMessageConverter
<?>>
converters
)
{
converters
.
add
(
stringConverter
);
...
...
@@ -176,7 +181,7 @@ public class DelegatingWebMvcConfigurationTests {
@Test
public
void
configureExceptionResolvers
()
throws
Exception
{
List
<
WebMvcConfigurer
>
configurers
=
new
ArrayList
<>();
configurers
.
add
(
new
WebMvcConfigurer
Adapter
()
{
configurers
.
add
(
new
WebMvcConfigurer
()
{
@Override
public
void
configureHandlerExceptionResolvers
(
List
<
HandlerExceptionResolver
>
exceptionResolvers
)
{
exceptionResolvers
.
add
(
new
DefaultHandlerExceptionResolver
());
...
...
@@ -195,7 +200,7 @@ public class DelegatingWebMvcConfigurationTests {
final
UrlPathHelper
pathHelper
=
mock
(
UrlPathHelper
.
class
);
List
<
WebMvcConfigurer
>
configurers
=
new
ArrayList
<>();
configurers
.
add
(
new
WebMvcConfigurer
Adapter
()
{
configurers
.
add
(
new
WebMvcConfigurer
()
{
@Override
public
void
configurePathMatch
(
PathMatchConfigurer
configurer
)
{
configurer
.
setUseRegisteredSuffixPatternMatch
(
true
)
...
...
spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolutionIntegrationTests.java
浏览文件 @
7df3d68b
...
...
@@ -40,7 +40,7 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
import
org.springframework.web.servlet.view.groovy.GroovyMarkupConfigurer
;
import
org.springframework.web.servlet.view.tiles3.TilesConfigurer
;
import
static
org
.
junit
.
Assert
.
*
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
* Integration tests for view resolution with {@code @EnableWebMvc}.
...
...
@@ -128,7 +128,7 @@ public class ViewResolutionIntegrationTests {
}
@EnableWebMvc
static
abstract
class
AbstractWebConfig
extends
WebMvcConfigurerAdapt
er
{
static
abstract
class
AbstractWebConfig
implements
WebMvcConfigur
er
{
@Bean
public
SampleController
sampleController
()
{
...
...
spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportTests.java
浏览文件 @
7df3d68b
...
...
@@ -18,7 +18,6 @@ package org.springframework.web.servlet.config.annotation;
import
java.util.List
;
import
java.util.Locale
;
import
javax.servlet.http.HttpServletRequest
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
...
@@ -363,7 +362,7 @@ public class WebMvcConfigurationSupportTests {
@EnableWebMvc
@Configuration
static
class
CustomViewResolverOrderConfig
extends
WebMvcConfigurerAdapt
er
{
static
class
CustomViewResolverOrderConfig
implements
WebMvcConfigur
er
{
@Override
public
void
configureViewResolvers
(
ViewResolverRegistry
registry
)
{
...
...
@@ -374,7 +373,7 @@ public class WebMvcConfigurationSupportTests {
@EnableWebMvc
@Configuration
static
class
CustomArgumentResolverConfig
extends
WebMvcConfigurerAdapt
er
{
static
class
CustomArgumentResolverConfig
implements
WebMvcConfigur
er
{
@Override
public
void
addArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
resolvers
)
{
...
...
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java
浏览文件 @
7df3d68b
...
...
@@ -50,13 +50,21 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
org.springframework.web.servlet.DispatcherServlet
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
Adapter
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
org.springframework.web.util.UriComponents
;
import
org.springframework.web.util.UriComponentsBuilder
;
import
static
org
.
hamcrest
.
Matchers
.*;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
springframework
.
web
.
servlet
.
mvc
.
method
.
annotation
.
MvcUriComponentsBuilder
.*;
import
static
org
.
hamcrest
.
Matchers
.
contains
;
import
static
org
.
hamcrest
.
Matchers
.
containsInAnyOrder
;
import
static
org
.
hamcrest
.
Matchers
.
endsWith
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
hamcrest
.
Matchers
.
startsWith
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
springframework
.
web
.
servlet
.
mvc
.
method
.
annotation
.
MvcUriComponentsBuilder
.
fromController
;
import
static
org
.
springframework
.
web
.
servlet
.
mvc
.
method
.
annotation
.
MvcUriComponentsBuilder
.
fromMethodCall
;
import
static
org
.
springframework
.
web
.
servlet
.
mvc
.
method
.
annotation
.
MvcUriComponentsBuilder
.
fromMethodName
;
import
static
org
.
springframework
.
web
.
servlet
.
mvc
.
method
.
annotation
.
MvcUriComponentsBuilder
.
on
;
/**
* Unit tests for {@link org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder}.
...
...
@@ -500,7 +508,7 @@ public class MvcUriComponentsBuilderTests {
@EnableWebMvc
static
class
WebConfig
extends
WebMvcConfigurerAdapt
er
{
static
class
WebConfig
implements
WebMvcConfigur
er
{
@Bean
public
PersonsAddressesController
controller
()
{
...
...
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java
浏览文件 @
7df3d68b
...
...
@@ -65,10 +65,10 @@ import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import
org.springframework.web.multipart.support.StandardServletMultipartResolver
;
import
org.springframework.web.servlet.DispatcherServlet
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
Adapter
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
static
org
.
junit
.
Assert
.
*
;
import
static
org
.
springframework
.
web
.
bind
.
annotation
.
RequestMethod
.
*
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
springframework
.
web
.
bind
.
annotation
.
RequestMethod
.
POST
;
/**
* Test access to parts of a multipart request with {@link RequestPart}.
...
...
@@ -198,7 +198,7 @@ public class RequestPartIntegrationTests {
@Configuration
@EnableWebMvc
static
class
RequestPartTestConfig
extends
WebMvcConfigurerAdapt
er
{
static
class
RequestPartTestConfig
implements
WebMvcConfigur
er
{
@Bean
public
RequestPartTestController
controller
()
{
...
...
src/docs/asciidoc/web/web-cors.adoc
浏览文件 @
7df3d68b
...
...
@@ -125,7 +125,7 @@ Enabling CORS for the whole application is as simple as:
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void addCorsMappings(CorsRegistry registry) {
...
...
@@ -142,7 +142,7 @@ specific path pattern:
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void addCorsMappings(CorsRegistry registry) {
...
...
src/docs/asciidoc/web/web-mvc.adoc
浏览文件 @
7df3d68b
...
...
@@ -4522,7 +4522,7 @@ a `CacheControl` instance, which supports more specific directives:
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
...
...
@@ -4935,7 +4935,7 @@ It also automatically registers the following well-known modules if they are det
[[mvc-config-customize]]
=== Customizing the Provided Configuration
To customize the default configuration in Java you simply implement the
`WebMvcConfigurer` interface or more likely extend the class `WebMvcConfigurer
Adapter
`
`WebMvcConfigurer` interface or more likely extend the class `WebMvcConfigurer`
and override the methods you need:
[source,java,indent=0]
...
...
@@ -4943,7 +4943,7 @@ and override the methods you need:
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
// Override configuration methods...
...
...
@@ -4970,7 +4970,7 @@ register custom formatters and converters, override the `addFormatters` method:
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void addFormatters(FormatterRegistry registry) {
...
...
@@ -5064,7 +5064,7 @@ Alternatively you can configure your own global `Validator` instance:
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public Validator getValidator(); {
...
...
@@ -5129,7 +5129,7 @@ An example of registering interceptors in Java:
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void addInterceptors(InterceptorRegistry registry) {
...
...
@@ -5183,7 +5183,7 @@ Below is an example of customizing content negotiation options through the MVC J
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
...
...
@@ -5242,7 +5242,7 @@ An example of forwarding a request for `"/"` to a view called `"home"` in Java:
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
...
...
@@ -5274,7 +5274,7 @@ JSON rendering:
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
...
...
@@ -5331,7 +5331,7 @@ In Java config simply add the respective "Configurer" bean:
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
...
...
@@ -5370,7 +5370,7 @@ to serve resource requests with a URL pattern of `/resources/{asterisk}{asterisk
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
...
...
@@ -5396,7 +5396,7 @@ browser cache and a reduction in HTTP requests made by the browser:
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
...
...
@@ -5430,7 +5430,7 @@ serving of resources from both the web application root and from a known path of
----
@EnableWebMvc
@Configuration
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
...
...
@@ -5477,7 +5477,7 @@ Java config example;
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
...
...
@@ -5544,7 +5544,7 @@ To enable the feature using the default setup use:
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
...
...
@@ -5576,7 +5576,7 @@ then the default Servlet's name must be explicitly provided as in the following
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
...
...
@@ -5609,7 +5609,7 @@ Below is an example in Java config:
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
...
...
@@ -5658,9 +5658,9 @@ And the same in XML, use the `<mvc:path-matching>` element:
=== Message Converters
Customization of `
HttpMessageConverter
` can be achieved in Java config by overriding
{api-spring-framework}/web/servlet/config/annotation/WebMvcConfigurer
Adapter
.html#configureMessageConverters-java.util.List-[`
configureMessageConverters
()
`]
{api-spring-framework}/web/servlet/config/annotation/WebMvcConfigurer.html#configureMessageConverters-java.util.List-[`
configureMessageConverters
()
`]
if you want to replace the default converters created by Spring MVC, or by overriding
{api-spring-framework}/web/servlet/config/annotation/WebMvcConfigurer
Adapter
.html#extendMessageConverters-java.util.List-[`
extendMessageConverters
()
`]
{api-spring-framework}/web/servlet/config/annotation/WebMvcConfigurer.html#extendMessageConverters-java.util.List-[`
extendMessageConverters
()
`]
if you just want to customize them or add additional converters to the default ones.
Below is an example that adds Jackson JSON and XML converters with a customized
...
...
@@ -5671,7 +5671,7 @@ Below is an example that adds Jackson JSON and XML converters with a customized
----
@Configuration
@EnableWebMvc
public class WebConfiguration
extends WebMvcConfigurerAdapt
er {
public class WebConfiguration
implements WebMvcConfigur
er {
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
...
...
@@ -5779,7 +5779,7 @@ or a single `@EnableWebMvc` annotated class, since they both register the same u
beans.
Modifying beans in this way does not prevent you from using any of the higher-level
constructs shown earlier in this section. `
WebMvcConfigurer
Adapter
` subclasses and
constructs shown earlier in this section. `
WebMvcConfigurer
` subclasses and
`
WebMvcConfigurer
` implementations are still being used.
====
...
...
src/docs/asciidoc/web/web-view.adoc
浏览文件 @
7df3d68b
...
...
@@ -47,7 +47,7 @@ Configuring the Groovy Markup Template Engine is quite easy:
----
@Configuration
@EnableWebMvc
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
...
...
@@ -1385,7 +1385,7 @@ provided with Java 8+, you should declare the following configuration:
----
@Configuration
@EnableWebMvc
public class MustacheConfig
extends WebMvcConfigurerAdapt
er {
public class MustacheConfig
implements WebMvcConfigur
er {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
...
...
@@ -1472,7 +1472,7 @@ browser facilities not available in the server-side script engine.
----
@Configuration
@EnableWebMvc
public class MustacheConfig
extends WebMvcConfigurerAdapt
er {
public class MustacheConfig
implements WebMvcConfigur
er {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
...
...
@@ -1746,7 +1746,7 @@ regular MVC annotation configuration.
@EnableWebMvc
@ComponentScan
@Configuration
public class WebConfig
extends WebMvcConfigurerAdapt
er {
public class WebConfig
implements WebMvcConfigur
er {
@Bean
public XsltViewResolver xsltViewResolver() {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录