diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java index 22ebd40f93..f4398accce 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java @@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.thymeleaf; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; +import java.util.List; import javax.annotation.PostConstruct; @@ -55,6 +56,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; +import org.springframework.http.MediaType; import org.springframework.util.MimeType; import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter; @@ -252,8 +254,10 @@ public class ThymeleafAutoConfiguration { ThymeleafReactiveViewResolver resolver = new ThymeleafReactiveViewResolver(); resolver.setTemplateEngine(templateEngine); resolver.setDefaultCharset(this.properties.getEncoding()); - resolver.setSupportedMediaTypes( - this.properties.getReactive().getMediaTypes()); + final List mediaTypes = this.properties.getReactive().getMediaTypes(); + if (mediaTypes != null) { + resolver.setSupportedMediaTypes(mediaTypes); + } resolver.setExcludedViewNames(this.properties.getExcludedViewNames()); resolver.setViewNames(this.properties.getViewNames()); if (this.properties.getReactive().getMaxChunkSize() > 0) { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java index daa5386a72..e403f505b6 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafProperties.java @@ -17,8 +17,6 @@ package org.springframework.boot.autoconfigure.thymeleaf; import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -227,8 +225,7 @@ public class ThymeleafProperties { /** * Media types supported by the view technology. */ - private List mediaTypes = new ArrayList<>( - Collections.singletonList(MediaType.TEXT_HTML)); + private List mediaTypes; public List getMediaTypes() { return this.mediaTypes; diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 5a62db5471..f5c55b3910 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -441,7 +441,7 @@ content into your application; rather pick only the properties that you need. spring.thymeleaf.mode=HTML5 # Template mode to be applied to templates. See also StandardTemplateModeHandlers. spring.thymeleaf.prefix=classpath:/templates/ # Prefix that gets prepended to view names when building a URL. spring.thymeleaf.reactive.max-chunk-size= # Maximum size of data buffers used for writing to the response, in bytes. - spring.thymeleaf.reactive.media-types=text/html # Media types supported by the view technology. + spring.thymeleaf.reactive.media-types= # Media types supported by the view technology. spring.thymeleaf.servlet.content-type=text/html # Content-Type value written to HTTP responses. spring.thymeleaf.suffix=.html # Suffix that gets appended to view names when building a URL. spring.thymeleaf.template-resolver-order= # Order of the template resolver in the chain.