Allow user to opt out of ContentNegotiatingViewResolver
The bean ID for the ContentNegotiatingViewResolver is now "viewResolver" (it is the *one*). The conditions have been changed so that a user only has to define a bean of the same name to switch it off. Fixes gh-546
This commit is contained in:
@@ -182,9 +182,9 @@ public class ThymeleafAutoConfiguration {
|
||||
"excludedViewNames", String[].class));
|
||||
resolver.setViewNames(this.environment.getProperty("viewNames",
|
||||
String[].class));
|
||||
// Needs to come before any fallback resolver (e.g. a
|
||||
// InternalResourceViewResolver)
|
||||
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 20);
|
||||
// This resolver acts as a fallback resolver (e.g. like a
|
||||
// InternalResourceViewResolver) so it needs to have low precedence
|
||||
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5);
|
||||
return resolver;
|
||||
}
|
||||
|
||||
|
||||
@@ -179,8 +179,8 @@ public class WebMvcAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(ViewResolver.class)
|
||||
public ContentNegotiatingViewResolver contentNegotiatingViewResolver(
|
||||
BeanFactory beanFactory) {
|
||||
@ConditionalOnMissingBean(name = "viewResolver")
|
||||
public ContentNegotiatingViewResolver viewResolver(BeanFactory beanFactory) {
|
||||
ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
|
||||
resolver.setContentNegotiationManager(beanFactory
|
||||
.getBean(ContentNegotiationManager.class));
|
||||
|
||||
Reference in New Issue
Block a user